我正在编写我的angularjs指令,其定义如下:
return {
restrict: 'EA',
link: link,
scope: true,
transclude: true,
replace: true,
controller: controller,
template: '<div class="wizard">' +
'<div ng-transclude></div>' +
'</div>'
};
Run Code Online (Sandbox Code Playgroud)
我注意到创建了两个范围:
< Scope (003) --- parent scope of directive
< Scope (004) --- controller scope of directive which I think is child scope created by 'scope=true'. all my functions, properites defined in controller show up in this scope
< Scope (005) --- transclude scope which is empty
Run Code Online (Sandbox Code Playgroud)
从文档我期望只创建一个子范围,因为'scope = true'不会创建一个孤立的范围.这导致所有被'ng-transclude'替换的元素实际上继承了Scope(005)并且无法访问我在控制器中定义的函数/属性,因为它们在Scope(004)中,它是Scope(005)的兄弟.
我不知道出了什么问题,有人可以在这里点灯吗?
当使用Chrome调试器观察我的元素时,我注意到这些元素是由"ng-scope"类添加的,但是,如何将"ng-scope"与batarang控制台中显示的范围相匹配?比如show ng-scope的id.
谢谢