2016-08-28 3 views
0

から表示されない:NG-繰り返し、私は私の工場からいくつかのデータを得ることができない私の工場

.factory("userDataFactory", function(){ 

    var user; 
    var user_notes; 

    var interfaz = { 
     getUsuario: function(){ 
     return user; 
     }, 
     getNotes: function(){ 
     return user_notes; 
     }, 
     nuevoUsuario: function(userId, email){ 
      user = [userId, email]; 
     }, 
     addNotes: function(notes){ 
      user_notes = notes; 
     } 
    } 

    return interfaz; 
}) 

私が最初に行うことは、このコードを使用して、私のRuby APIからデータを工場出荷時に移入することです:

$http({ 
      method : "POST", 
      url: "http://localhost:3000/api/v1/checkuser", 
      data: json 
      }).then (function mySucces(response){ 

       userDataFactory.nuevoUsuario(response.data.user[0].id, response.data.user[0].email); 
       userDataFactory.addNotes(response.data.notes); 
       $state.go('thirdday'); 

.controller('ListNotes', function($scope, userDataFactory, $state){ 

    $scope.notes = userDataFactory.getNotes(); 
    console.log($scope.notes); 
    //console.log($scope.notes[0].note1); 
}) 

そして最後に、私のhtml(listnotesでそれを表示しようとしている:Imは新しいコントローラに私の工場を呼んで

以降。 HTML)

<div class="list"> 

    <a class="item" href="#" ng-repeat="x in notes"> 
     {{ x.note2 }} 

    </a> 
</div> 

念のため、私のルートの設定:

.state('list',{ 
    url: '/listnotes', 
    templateUrl: 'templates/listnotes.html', 
    controller: 'ListNotes' 
    }) 

ので、私は何をしないのですか?なぜ私はAPIから得たすべてのノートを表示していないのですか?事前に

おかげ

EDIT

私は私のAPIからデータを取得した後、私は「thirdday.html]ビューに移動し、私はちょうど、リストビューに移動するボタンを押してください。あなたの工場「user_notes」は、

.state('thirdday',{ 
    url: '/thirdday', 
    templateUrl: 'templates/thirdday.html', 
    controller: 'Notes' 
    }) 

答えて

0

htmlに{{notes}}のメモを追加してみてください。そこに価値があるかどうかを見てください。 マークアップにng-appまたはng-controllerまたはsometingを追加しないでください

関連する問題