自定义了一个指令,想在一个页面中多次使用,每个指令传入的参数不同,如何让他获取对应参数取得的值
html
js
app.directive('selectOption',function($http){
return{
restrict:'E',
scope :'' ,
link:function(scope, element, attrs) {
scope.title = attrs.title;
scope.grup = attrs.grup;
scope.list = attrs.grup;
var data = {
'groupName':attrs.title
};
scope.ceshi = function(a){
alert(a);
}
$http.post('/datadicItem/findItemsByGroupName',data,postCfg)
.success(function(resp){
// debugger
scope.list = resp;
console.log(scope.list);
});
},
template:''+
' '+
' {{title}}'+
''+
''+
''+
'
',
replace:true,
};
});
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
option选项里的具体内容 如果是经常变的 要向后端发起请求获取 如果是性别只有男女这种 就可以写在controller里面
下面具体代码没看完,就独立指令,上面应该这么写: