1、&
绑定function
function metadataManagement(PathUtils) {
return {
restrict: 'E',
bindToController: {
title:"@",
values: "=", //所有的元数据
deleteFunc: "&", //删除触发的方法,需要接收object对象与callback
enableFunc: "&?" //?为可双向绑定,可传可不传
},
controller: [MetadataManagementDir],
controllerAs: 'metadataManagementDir'
}
}
function delet(index) {
vm.values[index].inuse = false;
if (vm.deleteFunc != null) {
vm.deleteFunc({
obj: vm.values[index],
callback: function () {}
});
}
}
function enable(index) {
vm.values[index].inuse = true;
if (vm.enableFunc != null) {
vm.enableFunc({
obj: vm.values[index],
callback: function () {}
});
}
}
传值:
<metadata-management
delete-func="cultivationProcedureCategoryCtrl.deleteFunc(obj,callback)"
enable-func="cultivationProcedureCategoryCtrl.enableFunc(obj,callback)">
</metadata-management>
function deleteFunc(obj, callback) {
ecnuCultivationProcedureCategoryDao.disableById(obj.id, callback);
}
function enableFunc(obj, callback) {
ecnuCultivationProcedureCategoryDao.enableById(obj.id, callback);
}
2、=
双向绑定数据
<metadata-management values="cultivationProcedureCategoryCtrl.values">
</metadata-management>
3、@
仅单向绑定,不同于=传递值,只传递字符
<metadata-management title="元数据管理">
</metadata-management>