这里我的问题:ng表中的数据没有显示
我想建立一个指令在角度,这将使用ng表内。我正在使用模拟数据。问题是我无法在表格中呈现数据。这里是我的指令:
;(function(app) {
app.directive('customTables', [
'NgTableParams',
function(NgTableParams) {
return {
restrict: 'E',
templateUrl: 'templates/directives/table_directive.html',
scope: {
},
link: function(scope) {
var dataset = [{
name: "Moroni50",
age: "50"
}, {
name: "Moroni49",
age: "49"
}];
scope.tableParams = new NgTableParams({}, {
data: dataset
});
}
};
}]);
})(app);
下面是HTML:
<table ng-table="tableParams" class="table table-bordered table-striped table-condensed">
<tr ng-repeat="user in $data">
<td title="'Name'" filter="{ name: 'text'}" sortable="'name'">{{user.name}}</td>
<td title="'Age'" filter="{ age: 'number'}" sortable="'age'">{{user.age}}</td>
</tr>
这里是我怎么称呼它:
<custom-table></custom-table>
有什么建议?
更改您的指令'ngTable',不'ngTables' – raven
这不是因为指令名的,问题是,数据是空的 – fishera
从那里你得到'$ data'的名字? – Sravan