2016-12-23 3 views
0

以下のコードではmock.jsonファイルの値を印刷したいと思います。 私はこのコードでangularjs.inを使用しています 私はajaxコールの結果をajaxコールから得ました。何もありません(応答変数は空です).i am new with angularjs何が間違っているか教えてください。あなたのコードで私は下のプログラムでangularjsを使用してPHPに取り組んでいます。私はdidntはajax call.iからの応答を取得しませんでした何かを間違ったコードを取得する

<!doctype html> 
<html lang="en" ng-app="angularTable"> 

    <script src="lib/angular/angular.js"></script> 
    <script src="lib/dirPagination.js"></script> 
    <script > 
    var app=angular.module('angularTable',[]); 
    app.controller('listdata',function($scope,$http) { 
     $scope.users=[]; 
     $http.get("mockJson/mock.json").success(function(responce){ 
      $scope.users = response; 
     }) 
     .error(function(data) { 
      console.error('Repos error', data); 
     }) 
    }); 

    </script> 
<body> 
    <div ng-controller="listdata"> 
     <table> 
      <tr> 
       <th>Id</th> 
       <th>Name</th> 
      </tr> 
      <tr ng-repeat="users in users"> 
       <td>{{users.id }}</td> 
       <td>{{users.first_name }}</td> 
      </tr> 
     </table> 
    </div> 
</body> 
</html> 


///Json File(mock.json) 

[{"id":1,"first_name":"Heather","last_name":"Bell","hobby":"Eating"}, 
{"id":2,"first_name":"Andrea","last_name":"Dean","hobby":"Gaming"}, 
{"id":3,"first_name":"Peter","last_name":"Barnes","hobby":"Reading Books"}, 
{"id":4,"first_name":"Harry","last_name":"Bell","hobby":"Youtubing"}, 
{"id":5,"first_name":"Deborah","last_name":"Burns","hobby":"Fishing"}, 
{"id":6,"first_name":"Larry","last_name":"Kim","hobby":"Skipping"}, 
{"id":7,"first_name":"Jason","last_name":"Wallace","hobby":"Football"}, 
{"id":8,"first_name":"Carol","last_name":"Williams","hobby":"Baseball"}, 
{"id":9,"first_name":"Samuel","last_name":"Olson","hobby":"Programming"}, 
{"id":10,"first_name":"Donna","last_name":"Evans","hobby":"Playing DOTA"}, 
{"id":11,"first_name":"Lois","last_name":"Butler","hobby":"Gaming"}, 
{"id":12,"first_name":"Daniel","last_name":"Hill","hobby":"surfing"}, 
{"id":13,"first_name":"Matthew","last_name":"Torres","hobby":"cycling"}, 
{"id":14,"first_name":"Jerry","last_name":"Hernandez","hobby":"Music"}, 
{"id":15,"first_name":"Christopher","last_name":"Carpenter","hobby":"Football"}, 
{"id":16,"first_name":"Harold","last_name":"West","hobby":"Gaming"}, 
{"id":17,"first_name":"Carol","last_name":"Hicks","hobby":"Youtubing"}, 
{"id":18,"first_name":"Bonnie","last_name":"Davis","hobby":"Partying"}, 
{"id":19,"first_name":"Nancy","last_name":"Banks","hobby":"Photography"}, 
{"id":20,"first_name":"Walter","last_name":"Freeman","hobby":"Tweeting"}, 
{"id":21,"first_name":"Louis","last_name":"Gonzales","hobby":"Bloging"}, 
{"id":22,"first_name":"Jean","last_name":"Watkins","hobby":"Bloging"}, 
{"id":23,"first_name":"Albert","last_name":"Harris","hobby":"Music"}, 
{"id":24,"first_name":"Billy","last_name":"Owens","hobby":"Camping"}, 
{"id":25,"first_name":"Russell","last_name":"Patterson","hobby":"Singing"}] 

答えて

0

$scope.usersに割り当てられている変数が応答ありながら

$http.get("mockJson/mock.json").success(function(responce){ 

    $scope.users = response; 
}) 

関数の引数は、responceです。

関連する問題