2015-11-08 64 views
0

我試圖將2個partials路由到我的索引頁面,但到目前爲止只有一條路徑似乎工作,另一條路徑沒有響應。我已經經歷過很多次這些代碼,但似乎無法發現問題。希望得到任何見解。角度路線不工作,你能發現錯誤嗎?

赫雷什是我的控制器:

app.controller('HomeController', ['$scope','stream', function($scope, stream) { 
    stream.then(function(data) { 
     $scope.photos = data; 
    }); 
}]); 

這是控制器,用於失敗的部分加載

app.controller('PhotoController', ['$scope','stream', '$routeParams', function($scope, stream, $routeParams) { 
    stream.then(function(data) { 
     $scope.descript = data.items[$routeParams.photoid]; 
    }); 
}]); 

這是

<div class="container" ng-repeat="photo in photos.items" > 
    <div class="photo" >   
     <div> 
     <img class="col-md-2 thumbnail" ng-src="{{photo.media.m}}"> 
     </div> 
     <div class="col-md-8" style="height: 119px; width: 641px"> 
     <div class="row" id="title"><p1>{{photo.title}}</p1></div> 
     <div class="row list-desc"> 
     <p1 id="author">{{photo.author}}</p1> 
     <p1 id="pub-date">Published:{{photo.published | date}}</p1> 
     <a id="view-link" href="description/{{$index}}">View on flickr</a> 
      </div> 
     </div>   
    </div> 
</div> 

這是失敗的一個加載。

<div class="container" ng-repeat="desc in descript" > 
      <h1>{{desc.title}}</h1> 
</div> 

這是我的路由:

var app = angular.module('angularOne', ['ngRoute']); 

app.config(['$routeProvider','$locationProvider', 
    function($routeProvider, $locationProvider) { 
     $routeProvider. 
     when('/', { 
      controller: 'HomeController', 
      templateUrl: 'views/home.html' 
     }). 
     when('/description/:photoid', { 
      controller: 'PhotoController', 
      templateUrl: 'views/photo.html' 
     }). 
     otherwise({ 
     redirectTo:'/' 
     }); 

    $locationProvider.html5Mode(true); 
}]); 
+0

您的路線配置在哪裏? – ivamax9

+0

你是否收到任何錯誤訊息? – LeFex

+0

@chase只是附加了路由配置代碼。 – CodeArt

回答

0

遞減應該在html DESCRIPT,或在JS的其他方式。

+0

desc只是循環遍歷描述並顯示在html部分中。 – CodeArt

+0

然後,我和LeFex一起,它可能只是文件路徑中某個地方的錯字。 –

+0

我會再看看它,我希望我找到一些東西。 – CodeArt