我是角度js的新手。我想使用ng-repeat从http重新获取内容来重复列表。但不幸的是,我在位置40的JSON中获得了意外的令牌。
这是我的代码
<!DOCTYPE>
<html ng-app="easternApp">
<body ng-controller="easternController">
<div class="clearfix blogs" ng-repeat=" item in homelist | orderBy: 'title' | limitTo: 5">
<h2>
<a href="#" ng-bind="item.title"></a>
</h2>
<figure><img ng-src="{{ item.imgpath }}" alt="" /></figure>
<div class="blogicon clearfix">
<div class="blog_collectinfo">
<i class="flaticon-small-calendar"></i>
<span ng-bind="item.post_date | date: 'medium'"></span>
</div>
<div class="blog_collectinfo">
<i class="flaticon-chat"></i>
<span ng-bind="item.treatments"></span>
</div>
<div class="blog_collectinfo">
<i class="flaticon-eye"></i>
<span ng-bind="item.view"> views</span>
</div>
</div>
<article class="blogcontent">
<p ng-bind="item.blogcontent | limitTo: 250"></p>
</article>
</div>
<script>
var eastern_app = angular.module('easternApp', ['ui.bootstrap']);
eastern_app.controller("easternController", function($scope, $http, $sce) {
var homelist_file = "files/homelist_file.json";
$http({
method: "GET",
url: homelist_file,
contentType: "application/json; ",
dataType: "json",
}).then(function(response) {
$scope.homelist = response.data.homelist_list;
});
});
</script>
</body>
</html>
我的json文件的链接是
http://pixperfectionist.in/work/dump/homelist_file.json
我是角度js的新手。我想使用ng-repeat从http重新获取内容来重复列表。但不幸的是,我在位置40的JSON中获得了意外的令牌。请帮我解决问题。
提前致谢
答案 0 :(得分:1)
片段
treatments: 34 + ' treatments',
不是有效的JSON值。它不是字符串也不是数字。它应该只是
"treatments": "34 treatments",
使用在线JSON验证器是解决此类问题的最佳方法。