Angularjs 在ionic中,我无法从json文件中获取数据

Angularjs 在ionic中,我无法从json文件中获取数据,angularjs,ionic-framework,Angularjs,Ionic Framework,我无法获取json文件数据 这是我的代码,请帮我解决这个问题 html代码是 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title&

我无法获取json文件数据 这是我的代码,请帮我解决这个问题 html代码是

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

       <script src="js/app.js"></script>
    <script src="js/data.json"></script>
  </head>
  <body ng-app="starter">

    <ion-pane>
      <ion-header-bar class="bar-dark">
        <h2 class="title">Artist List</h2>
      </ion-header-bar>

  <div class="bar bar-subheader
      item-input-inset bar-light">
     <label class="item-input-wrapper">
        <i class="icon ion-search"></i>
        <input type="search" placeholder="Search">
     </label>
  </div>

      <ion-content ng-controller="ListController"
      class="has-subheader">
        <ion-list>
          <ion-item ng-repeat='item in artists'
           class="item-thumbnail-left item-text-wrap">
          <img src="img/{{item.shortname}}_tn.jpg" alt="{{item.name}} Photo" >
          <h2>{{item.name}}</h2>
          <h3>{{item.reknown}}</h3>
          <p>{{item.bio}}</p>

        </ion-item>
      </ion-list>
      </ion-content>
    </ion-pane>
  </body>
</html>
data.json文件是

 .controller('ListController', ['$scope', '$http', function($scope, $http){
    $http.get('js/data.json').success(function(data){
      $scope.artists = data;
    });
    }]);
[
{
  "shortname": "Barot_Bellingham",
  "name": "Barot Bellingham",
  "reknown": "Royal Academy of Painting and Sculpture",
  "bio": "Barot has just finished his final year at The Royal Academy",        
},
{
  "shortname": "Constance_Smith",
  "name": "Constance Smith",
  "reknown": "Academy of Painting and Sculpture",
  "bio": "Smith has just finished his final year at The Royal Academy",        
}
]

这是工作链接
http://plnkr.co/edit/soWghwLtwXtjQC1ZnmTC?p=preview

我在您的JSON文件中发现一个问题,即您的数据在每个块中都以逗号结尾,因此无法将数据输入到程序中 因此,您的json应该如下所示

[
{
  "shortname": "Barot_Bellingham",
  "name": "Barot Bellingham",
  "reknown": "Royal Academy of Painting and Sculpture",
  "bio": "Barot has just finished his final year at The Royal Academy"      
},
{
  "shortname": "Constance_Smith",
  "name": "Constance Smith",
  "reknown": "Academy of Painting and Sculpture",
  "bio": "Smith has just finished his final year at The Royal Academy"       
}
]

这是工作链接
http://plnkr.co/edit/soWghwLtwXtjQC1ZnmTC?p=preview

我在您的JSON文件中发现一个问题,即您的数据在每个块中都以逗号结尾,因此无法将数据输入到程序中 因此,您的json应该如下所示

[
{
  "shortname": "Barot_Bellingham",
  "name": "Barot Bellingham",
  "reknown": "Royal Academy of Painting and Sculpture",
  "bio": "Barot has just finished his final year at The Royal Academy"      
},
{
  "shortname": "Constance_Smith",
  "name": "Constance Smith",
  "reknown": "Academy of Painting and Sculpture",
  "bio": "Smith has just finished his final year at The Royal Academy"       
}
]

这可能与您的问题无关,但是您应该考虑使用<代码>())/>代码>而不是<代码>继承()/代码>。 我认为自1.4.4以来,

success()
error()
的使用已经被贬低了

$http.get('js/data.json').then(function(data){
  // successcallback
}, function(error){
  // errorcallback
});

这可能与您的问题无关,但是您应该考虑使用<代码>())/>代码>而不是<代码>继承()/代码>。 我认为自1.4.4以来,

success()
error()
的使用已经被贬低了

$http.get('js/data.json').then(function(data){
  // successcallback
}, function(error){
  // errorcallback
});

好的,pankaj会尝试broit不起作用,我做了,你有什么错误吗?不,我没有任何错误Sok pankaj会尝试broit不起作用,我做了,你有什么错误吗?不,我没有任何错误,我也尝试了你说的方式,但同样没有起作用。没有问题……你能用它创建一个打劫器吗……你确定数据是正确的吗以正确的格式??你能看到的任何错误??我也尝试了你说的方式,但同样没有起作用。没有问题……你能用它创建一个plunker吗……你确定数据的格式正确吗??你能看到的任何错误??