【发布时间】:2015-04-10 01:35:52
【问题描述】:
scope: {
someProperty: "=?"
somePropertyTwo: =?Wheeeeee
}
“=”是什么意思?做?我在任何地方都找不到答案。我知道使用 scope: {} (或 scope: true )给指令一个新的范围,前者是一个隔离范围,后者是单向绑定到父 Ctrl (指令所在的页面/视图的 Ctrl用来)。我明白了:
someProp: @X //will one-way bind someProp to parent Ctrl's X
someProp: =X //two-way
someProp: &X() //some space magic for binding methods
但是,我不明白如何/为什么使用“=?”。
相关文章(仅涵盖前三篇): http://www.undefinednull.com/2014/02/11/mastering-the-scope-of-a-directive-in-angularjs/ http://weblogs.asp.net/dwahlin/creating-custom-angularjs-directives-part-2-isolate-scope
edit:和这些一样吗?
? - 尝试定位所需的控制器,如果未找到,则将 null 传递给链接 fn。 ^ - 通过搜索元素及其父元素找到所需的控制器。如果找不到则抛出错误。 https://docs.angularjs.org/api/ng/service/$compile#-require-
即如果没有找到任何属性,则传递 null ?
【问题讨论】:
标签: angularjs