angular.js - angular $http.get读取本地json出错
某草草
某草草 2017-05-15 16:58:50
0
1
579
  1. 描述你的问题:ionic app,angular读取本地json实现下拉刷新doRefresh,一直报错...

  2. 贴上相关代码:

    controller代码:
     $scope.doRefresh = function() {
        $http.get('json/news.json')
            .success(function (data) {
                $scope.items = data.news;
            })
            .finally(function() {
                $scope.$broadcast('scroll.refreshComplete');
            });
    };
    news.json代码:
     {
       "news":
      [
        {   
            "newsid":0,
            "title":"新闻一标题",
            "text":"大家好,我是新闻一o(^▽^)o",
            "img":"img/xinwen1.jpg",
        },
        {
            "newsid":1,
            "title":"新闻二标题",
            "text":"大家好,我是新闻二o(^▽^)o",
            "img":"img/xinwen2.jpg",
        }
      ]
     }
  3. 贴上报错信息:手机上调试报错信息,

  4. 贴上相关截图:这是我项目的目录结构,

某草草
某草草

reply all(1)
左手右手慢动作

Look at your error. There is a problem with JSON parsing.

Look at your json file again and you will find the problem.

JSON format requirements are very strict. There should be no comma after the last attribute value of each object in your JSON array.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template