问号在 Angular 隔离范围绑定中有什么作用?
What does the question mark do in an Angular isolate scope binding?
我看了很多解释@
、=
和&
之间区别的文章。我见过很多人在他们的代码中使用 =?
。这是什么意思?
不幸的是,我似乎无法在 Google 或 SO 上搜索答案,因为搜索引擎会忽略特殊字符。
?
使 属性 可选。否则,您将得到 NON_ASSIGNABLE_MODEL_EXPRESSION
,其中 Angular 正在寻找不存在的 属性。
来自文档:
If the parent scope property doesn't exist, it will throw a NON_ASSIGNABLE_MODEL_EXPRESSION exception. You can avoid this behavior using =? or =?attr in order to flag the property as optional.
我看了很多解释@
、=
和&
之间区别的文章。我见过很多人在他们的代码中使用 =?
。这是什么意思?
不幸的是,我似乎无法在 Google 或 SO 上搜索答案,因为搜索引擎会忽略特殊字符。
?
使 属性 可选。否则,您将得到 NON_ASSIGNABLE_MODEL_EXPRESSION
,其中 Angular 正在寻找不存在的 属性。
来自文档:
If the parent scope property doesn't exist, it will throw a NON_ASSIGNABLE_MODEL_EXPRESSION exception. You can avoid this behavior using =? or =?attr in order to flag the property as optional.