我是Angula JS的新手,我试图绑定一个表,但是ng-repeat没有在表中绑定。我在登录控制台时可以看到数据。没有显示错误消息。我的示例代码是 部分视图
<h3>List of Players</h3>
{{message}}
<table>
<tr>
<th>Name</th>
<th>Club</th>
<th>Country</th>
<th>Age</th>
</tr>
<tr ng-repeat="player in listPlayers">
<td>{{player.Name}}</td>
<td>{{player.Club}}</td>
<td>{{player.Country}}</td>
<td>{{player.Age}}</td>
</tr>
</table>
我的控制器代码是
angular.module("CrudDemoApp.controllers", []).
controller("MainController", function ($scope, PlayerService) {
$scope.message = "Main Controller";
PlayerService.GetPlayersFromDB().then(function (d) {
$scope.listPlayers = d.data.list;
console.log($scope.listPlayers);
});
})
我的App.js代码是
var app = angular.module("CrudDemoApp", ["CrudDemoApp.controllers", "ngRoute"]);
app.config(["$routeProvider", function ($routeProvider) {
$routeProvider.
when("/", {
templateUrl: "/Partials/PlayerList.html",
controller: "MainController"
}).
when("/AddPlayer",
{
templateUrl: "/Partials/AddPlayer.html",
controller: "AddPlayerController"
}).
when("/EditPlayer/:id", {
templateUrl: "/Partials/EditPlayer.html",
controller: "EditPlayerController"
}).
otherwise({ redirectTo: "/" });
}
])