【发布时间】:2015-08-21 18:26:42
【问题描述】:
我的指令使用代码
<input-select ng-model="someModel" ng-change="someFunction()"
options="countries"></input-select>
我的指令代码
.directive('inputSelect', function () {
return {
templateUrl: 'someTemplate.html',
restrict: 'E',
scope: {
ngModel: '=',
ngChange: '='
}
};
});
我的指令模板
<select
ng-model="ngModel" ng-init="ngModel "
ng-options="option[optionId] as option[optionName] for option in options"
ng-change="ngChange">
</select>
o,当所选项目更改时,函数 someFunction() @被召唤为无限时间(尽管更改完成了一次),应更改以确保 someFunction() get get on thow @ nofter @ get the @ get the someFunction() 987654326@ 是使用指令的控制器范围内的函数)
[ 我确实尝试将& 和@ 用于ngChange 的范围类型,如果使用它们,somefunction() 不会被触发。 ]
【问题讨论】:
标签: javascript angularjs angularjs-directive angularjs-scope ng-options