或者指令的controller可以获取element,attribute对象吗,想在子指令调取主指令controller方法,并在方法里面操作focus,但是在controller里操作element[0].focus()并没有使得光标定位,指令封装的是ng-repeat,因为link是在指令编译后执行的,所以直接在link里面写会没有响应
认证高级PHP讲师
http://stackoverflow.com/a/24...
The
link method has a fourth parameter, which represents the controller of the current directive or parent directive.
Write this in the command controller:
controller: function() { this.xxx = function() {} }
link in:
link: function(scope, elem, attr, parent) { parent.xxx() }
You can call methods in the controller directly in the link. On the other hand, if you call the method in link in the controller, you don't know how to operate it. . .
http://stackoverflow.com/a/24...
The
link method has a fourth parameter, which represents the controller of the current directive or parent directive.
Write this in the command controller:
link in:
You can call methods in the controller directly in the link. On the other hand, if you call the method in link in the controller, you don't know how to operate it. . .