我总是使用指令ngTable和ngRoute模块。但是,我最近迁移到了UI-Router,以便更好地适应我正在开发的项目。
但由于某种原因,ngTable无法与UI-Router一起正常工作。 该表是正常生成的,但设置没有。 它既不是头也不是分页。由于该小组也没有工作。
我还尝试手动创建表头,但是当我使用值“templates.header”添加属性“ng-include”时,我注意到它消失了。
我使用了以下版本:
ngTable - 1.0.0-beta.9
UI-Router - 0.2.15
有人遇到过这个问题吗?我无法在任何地方找到解决方案。
JavaScript:
app.controller("users", function($http, $rootScope, $stateParams, $scope, NgTableParams) {
$scope.users = {};
$http({
method: "POST",
url: "./controllers/users/read.php",
data: {
id: $stateParams.id,
language_id: $rootScope.globals.language.id
}
}).success(function(response) {
$scope.tableParams = new NgTableParams({
count: 10,
sorting: {
name: "asc"
}
}, {
dataset: response
});
$scope.users = response;
});
});
HTML:
<table ng-table="tableParams" class="table table-bordered table-striped">
<tr ng-repeat="row in $data">
<td data-title="'txt.pages.users.fields.name' | translate" sortable="'name'" width="45%">
{{ row.name }}
</td>
<td data-title="'txt.pages.users.fields.email' | translate" sortable="'email'" width="45%">
{{ row.email }}
</td>
<td data-title="'txt.pages.users.fields.actions' | translate" width="10%">
<button ng-click="edit(row.id)" class="btn btn-warning btn-sm">
<icon class="glyphicon glyphicon-edit"></icon>
</button>
<button ng-click="delete(row)" class="btn btn-danger btn-sm">
<icon class="glyphicon glyphicon-remove"></icon>
</button>
</td>
</tr>
</table>
stateProvider:
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider.state("site", {
url: "/",
views: {
"outside@": {
templateUrl: "./template/site/index/read.html"
},
"inside@site": {
templateUrl: "./template/site/home/read.html"
}
}
}).state("cms", {
url: "/cms",
views: {
"outside@": {
templateUrl: "./template/cms/index/read.html"
}
}
}).state("dashboard", {
parent: "cms",
url: "/dashboard",
views: {
"inside@cms": {
templateUrl: "./template/cms/dashboard/read.html"
}
}
}).state("login", {
parent: "cms",
url: "/login",
views: {
"inside@cms": {
templateUrl: "./template/cms/login/read.html"
}
}
}).state("users", {
parent: "cms",
url: "/users",
views: {
"inside@cms": {
controller: "users",
templateUrl: "./template/cms/users/read.html"
}
}
});
});
答案 0 :(得分:0)
我认为您应该在下面一行使用$users
代替$data
。
<tr ng-repeat="row in $data">