AngularJS指令控制器和要求
如何在Link函数中获取ngModel和SelectBoxController的实例 指令AngularJS指令控制器和要求,angularjs,angularjs-directive,angularjs-scope,Angularjs,Angularjs Directive,Angularjs Scope,如何在Link函数中获取ngModel和SelectBoxController的实例 指令 angular .module('directives.selectBox', []) .directive('selectBox', selectBox); function selectBox() { return { restrict : 'E', require : ['ngModel'], scope
angular
.module('directives.selectBox', [])
.directive('selectBox', selectBox);
function selectBox() {
return {
restrict : 'E',
require : ['ngModel'],
scope : {
list : '=',
},
replace : true,
templateUrl : 'common/directives/selectBox/selectBox.html',
controller : SelectBoxController,
link: function(scope, element, attrs, controllers) {
console.log(controllers);
}
};
}
使用“require”获取
ngModelController
和SelectBoxController
:
function selectBox() {
return {
restrict : 'E',
require : ['ngModel','selectBox'],
scope : {
list : '=',
},
replace : true,
templateUrl : 'common/directives/selectBox/selectBox.html',
controller : SelectBoxController,
link: function(scope, element, attrs, controllers) {
console.log(controllers[0]);
console.log(controllers[1]);
}
};
}
第二个控制器SelectBoxController呢??