2016-10-03 12 views
0

aboutus.htmlページは aboutus.html NGリピート内のメディアリストのコンテンツを除き、正しく表示されます。コンソールにエラーは表示されません。私はコード全体を含んでいません(より多くのスペースが必要です)。誰でも助けてくれますか?は角度ルーティング/ ng-repeatの問題を理解できませんでした。

 // factory here. 
     angular.module('vasuapp') 

    .factory('corporateFactory', function() { 

    // Implement two functions, one named getLeaders, 
    // the other named getLeader(index) 
    // Remember this is a factory not a service 

    var corpfac = {}; 

    var leadership = [ 
     { 
      id: 0, 
      name:"asdfd", 
      designation:"sgsdgg", 
      abbr: "fgdfvf",  
     }, 
     { 
      // similarly some other data here. 
     } ]; 

    corpfac.getLeader = function(){ 
    return leadership; 
    }; 
    corpfac.getLeaders = function(index) 
    { 
     return leadership[index]; 
    }; 
    return corpfac; 

}); 

    // app.js 
angular.module('vasuapp', ['ngRoute']) 
.config(function($routeProvider) { 
    $routeProvider 
     .when('/aboutus', {templateUrl:'./aboutus.html' , controller: 'AboutController'}) 
     .otherwise('/'); 
}) 

    // controller.js 

angular.module('vasuapp') 
    .controller ('AboutController',['$scope','corporateFactory', function($scope,corporateFactory){ 
    var leadership = corporateFactory.getLeader(); 
    $scope.leaders = this.leadership; 
}]) 

    // aboutus.html 

    <div class="row row-content"> 
    <div class="col-xs-12 col-sm-9"> 
     <h2>Corporate Leadership</h2> 
     <p> hi </p> 
     <ul class="media-list"> 
      <li class = "media" ng-repeat = "lead in leaders"> 
       <div class = "media-list tab-pane fade in active"> 
       <a ng-href="#/aboutus"> 
        <img class = "media-object" ng-src={{lead.image}} alt="author image"> 
       </a> 
       </div> 
       <div class = "media-body"> 
       <p>{{lead.description}}</p> 
       </div> 
      <footer> 
       -- {{lead.name}} the {{lead.designation}} 
       </footer> 
      </li> 
     </ul> 
    </div> 
+0

あなたの質問はあまり明確ではなく、実際にあなたが期待していることは述べていませんが、あなたは 'var leadership 'と' this.leadership'を同じ意味で使用しようとしているようです。同じものではありません。 – Claies

答えて

1

は、私が何をしたいことはあると思う:

$scope.leaders = corporateFactory.getLeader();

this.leadershipが定義されていません。

関連する問題