【发布时间】:2013-05-14 20:08:24
【问题描述】:
我是 Angular JS 的新手,我正在尝试创建一个自定义指令,如下所示:
<div linkedlist listcolumns="{{cashAccountsColumns}}"></div>
公司。 控制器将是:
$scope.cashAccountsColumns = [
{"field": "description", "title": "Description"},
{"field": "owner", "title":"Owner"},
{"field": "currentBalance", "title":"Current Balance" }
];
而指令代码是:
return {
restrict : 'EA',
transclude : false,
templateUrl : 'html/linkedlist.html',
scope: {
listcolumns: "@"
},
link : function(scope, element, attrs) {
}
}
模板是:
<table class="box-table" width="100%">
<thead>
<tr>
<th scope="col" ng-repeat="column in listcolumns">
{{column.title}}
</th>
</tr>
</thead>
</table>
但这不起作用。我没有在屏幕上获取 column.title 的值,而是将下面的太多行添加到 DOM:
<th ng-repeat="column in listcolumns" scope="col" class="ng-scope ng-binding"></th>
【问题讨论】:
-
如果您发现@Ajay beniwal 的答案有用,为什么不将其标记为答案?
-
原始发帖人看起来好像自从发帖后就没有回来了。
标签: angularjs angularjs-directive angularjs-ng-repeat