【发布时间】:2015-01-06 13:07:52
【问题描述】:
我为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'"}
那么,如何在指令中的元素中设置属性数组?
【问题讨论】:
标签: arrays angularjs angularjs-directive