0
我有一个HTML页面,那就是从js文件中调用JSON数据。 的HTML低于:JSON不显示在页面
<html>
<head>
<meta charset="UTF-8">
<script src="js/angular.js"></script>
<script src="js/angular-route.js"></script>
<script type="text/javascript" src="modules/app.js" ></script>
</script>
<title>
</title>
</head>
<body ng-app="albumsApp">
<div data-ng-controller="albumController">
<ul data-ng-repeat="album in albums">
<li>
{{albums.title}}
</li>
</ul>
</div>
</body>
</html>
的 “app.js” 它调用文件如下:
**
var albumsApp = angular.module ('albumsApp',[])
albumsApp.factory('albumFactory',function() {
return {
getAlbums: function(){
alert("test");
return [{"artist": "Kid 606","title:":"Happiness"}];
},
};
});
albumsApp.controller ('albumController', function ($scope,albumFactory) {
$scope.albums = albumFactory.getAlbums();
});
** 有也不在控制台时错误我运行它,只是没有出现。 当我加载页面时,警告框“测试”出现,因此函数被调用,它只是不显示JSON。谢谢你的回复。
通过album.title更换albums.title。并从json –
的“title:”键中删除尾部的':'使用'{{albums.title}}'的'{{album.title}}'即时' – vamsikrishnamannem