所以我遇到了很大的冲击,我没有在任何地方找到答案。 我试图获取JSON文件列表并使用Angular JS显示它们。
这是我的代码:
HTML:
mov eax,eax
角度服务:
<!doctype html>
<html lang="en" ng-app="estateApp">
<head>
<meta charset="utf-8">
<title>Case</title>
<link rel="stylesheet" href="bootstrap-3.3.6-dist/css/bootstrap.css" />
<link rel="stylesheet" href="css/app.css" />
<link rel="stylesheet" href="css/app.animations.css" />
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"> </script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/app.module.js"></script>
<script src="js/app.config.js"></script>
<script src="js/app.animations.js"></script>
<script src="core/core.module.js"></script>
<script src="core/checkmark/checkmark.filter.js"></script>
<script src="core/house/house.module.js"></script>
<script src="core/house/house.service.js"></script>
<script src="house-list/house-list.module.js"></script>
<script src="house-list/house-list.component.js"></script>
<script src="house-detail/house-detail.module.js"></script>
<script src="house-detail/house-detail.component.js"></script>
</head>
<body>
<div class="view-container">
<div ng-view class="view-frame"></div>
</div>
</body>
</html>
JSON示例:
'use strict';
angular.
module('core.house').
factory('House', ['$resource',
function($resource) {
return $resource('houses/:houseId.json', {}, {
query: {
method: 'GET',
params: {houseId: 'houses'},
isArray: true
}
});
}
]);
模板:
{
"name": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"utilities": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
],
"finishes": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
],
"end": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit."
],
"other-details": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
],
"location":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Price": "37.000 Euro",
"id": "house-1",
"images": [
"images/houses/casa-1.0",
"images/houses/casa-1.1",
"images/houses/casa-1.2",
"images/houses/casa-1.3",
"images/houses/casa-1.4"
],
"rooms":"3",
"area":"54 mp",
"partitioning":"circular",
"confort":"1",
"floor":"3/4",
"bathrooms":"1",
"balconies":"1"
}
我会根据要求提供任何其他文件,我暂时不知道该提供什么。
它来自他们网站上的角度教程,很奇怪,但它可以使用他们的JSON。
提前致谢!