0
我讀directive約ng-attr
,但我想給屬性的陣列指令爲例:屬性發送陣列指令
<myElement attributes="attributes"></myElement>
我的指令爲例:
myApp.directive('myElement', function(){
return {
restrict: 'E',
require: 'ngModel',
template: '<div>' +
'<!-- I want to add this attributes on the div element>' +
'</div>',
replace: true,
scope: {
attributes: '=attributes'
},
}
});
而且屬性在控制器中如下:
$scope.attributes = {"class": "test", "id": "test", "style": "color: 'red'"}
所以,How我可以在指令元素中設置數組屬性嗎?