我对 angularjs 和 onsenUI 非常陌生,一直在研究如何将来自 php url 的数据显示到我的页面中...
这是我的代码
Controller .js
angular.module('app').controller('CardController',['$scope','$http', function($scope, $http) {
$http.get('http://sth.sth.sth.php')
.success(function(data, status, headers, config) {
$scope.cards = data.cards;
})
.error(function(error, status, headers, config) {
console.log(error);
console.log("Error occured");
});
卡片.html
<div ng-controller="CardController">
<ul >
<li ng-repeat="item in cards track by $index">
{{cards.title}}
{{cards.id}}
</li>
</ul>
</div>
如果有人给我提供解决方法,我将不胜感激。 谢谢
最佳答案
它应该是 item
而不是 cards
-
<li ng-repeat="item in cards track by $index">
{{item.title}}
{{item.id}}
</li>
关于javascript - 使用 angularjs 从 php url 到 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32523349/