0

我正在尝试将 2 个部分路由到我的索引页面,但到目前为止,似乎只有一个路由有效,另一个没有响应。我已经多次查看代码,但似乎无法发现问题。将不胜感激任何见解。

这是我的控制器:

    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);
}]);
4

1 回答 1

0

desc 应该在 html 中描述,或者在 js 中描述。

于 2015-11-08T01:16:41.823 回答