【发布时间】:2018-06-13 14:23:01
【问题描述】:
ng-repeat 返回空白,我是 Angular 的新手。我检查了错误,但没有发现。我真的不知道这里出了什么问题。
(function() {
var app = angular.module("testApp", []);
app.controller("MainController", function($scope, $http) {
$scope.search = function(username) {
$http.get("https://api.github.com/users/" + username)
.then(onUserComplete, onError);
$http.get($scope.user.repos)
.then(onRepos, onReposError);
};
var onUserComplete = function(response) {
$scope.user = response.data;
};
var onRepos = function(response) {
$scope.repos = reponse.data;
};
});
}());
下面是 HTML,我想在 GitHub 上显示特定用户的存储库:
<table>
<thead>
<tr>
<th>Name</th>
<th>Stars</th>
<th>Language</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="repo in repos">
<td>{{repo.name}}</td>
<td>{{repo.stargazers_count }}</td>
<td>{{repo.language}}</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
谢谢@rrd 我不知道他们是不同的
标签: javascript angularjs promise