我在角度很新的,我在做一個應用程序,我使用ngTable:角指令顯示錯誤的地方
var app = angular.module('myApp', ["ngTable"]).controller('mainController', function($scope, NgTableParams) {
$scope.data = [
{
a : "3",
b : "test"
},
{
a : "3",
b : "test"
},
{
a : "3",
b : "test"
}
];
$scope.tableParams = new NgTableParams({}, { dataset: $scope.data});
});
app.directive('appInfo', function() {
return {
restrict: 'E',
scope: {
info: '=infoData'
},
template:
" <tr> " +
" <td filter=\"{ a: 'text'}\" sortable=\"'a'\">{{info.a}}</td> " +
" <td filter=\"{ b: 'text'}\" sortable=\"'b'\">{{info.b}}</td> " +
" </tr> "
};
});
這裏是HTML:
<div class="main" ng-app="myApp" ng-controller="mainController">
<table ng-table="tableParams" class="table" show-filter="true">
<thead>
<tr>
<th>A</th>
<th>B</th>
</tr>
</thead>
<tbody>
<app-info ng-repeat="info in data" info-data="info" />
</tbody>
</table>
</div>
的問題是,<app-info>
標籤將錯誤的地方,裏面div
的table
,而不是tbody
以上。我錯過了什麼?
發生了什麼:
<div class="main" ...>
<app-info ... />
<app-info ... />
...
<table ...
</div>
什麼是正確的:
<div class="main" ...>
<table ...>
<thead>...</thead>
<tbody>
<app-info ... />
<app-info ... />
...
</tbody>
...
</div>