我有这个代码
case 'ROLES':
if(scope.ersProfileEditableFieldValue){
scope.ersProfileSectionData[scope.field.code] = scope.ersProfileEditableFieldValue.map(function(val){return val.id});
}
scope.initRoles();
tpl ='<div ng-if ="roles.length>0">'
+'<ers-multi-selector ers-options="roles" on-change="test(message)"'
+' is-primary-selector="true" placeholder="Enter a Role" selected-options="ersProfileSectionData[field.code]">'
+' </ers-multi-selector></div>'
iAttrs.$observe('onChange', function(event, value){
console.log("here");
console.log(event);
console.log(value);
})
console.log(scope);
console.log(iElement);
console.log(iAttrs);
break;
在此 ers-multi-selector 中 自定义指令我必须找到 on-change 属性,这些属性具有测试方法,我如何才能找到该属性,以便我可以对其进行处理。
我正在展示这个插件的一些代码。
angular.module('ersMultiSelector',[]);
angular.module('ersMultiSelector').directive('ersMultiSelector', function(){
return{
scope: {
ersOptions: '=',
isPrimarySelector: '=',
placeholder: "@",
selectedOptions: '=',
onChange: '&'
},
controllerAs: 'vm',
bindToController: true,
templateUrl: 'libs/planner/ers-multi-selector/template/multi-selector.html',
controller : [function(){
var vm = this;
vm.addOption = function(toselect){
vm.onChange({"message":"i am working"});
toselect.isused = true;
vm.selectedOptions.push(toselect.id);
vm.selectedOptionsVirtual.push(getVoption(toselect.id,
toselect.name, vm.selectedOptions.length - 1, toselect));
vm.selected = undefined;
}
}]
}
});
答案 0 :(得分:0)
在link
controller
函数代替custom-directive
有关详细信息,请参阅以下链接中的custom指令的链接功能
https://cloud.google.com/compute/docs/access/user-accounts/api/latest/users/insert