0
你好人,所以我有一個控制器,我使用一些路由ID,所以我可以指示我的列表與它到另一個頁面。 我的控制器是這樣的:
RecordsControllers.controller('DetailsController', ['$scope', '$http','$routeParams', function($scope, $http, $routeParams) {
$http.get('js/data.json').success(function(data) {
$scope.records = data;
$scope.whichItem = $routeParams.itemId;
if ($routeParams.itemId > 0) {
$scope.prevItem = Number($routeParams.itemId)-1;
} else {
$scope.prevItem = $scope.records.length-1;
}
if ($routeParams.itemId < $scope.records.length-1) {
$scope.nextItem = Number($routeParams.itemId)+1;
} else {
$scope.nextItem = 0;
}
});
}]);
使用ID路由到我的詳細信息頁面像我的列表發送:
<li class="chat cf animation" ng-repeat="item in records | filter: query | orderBy: chatsOrder:direction | limitTo:limit">
<a href="#details/{{records.indexOf(item)}}" >
<!-- <img ng-src="images/{{item.shortname}}_tn.jpg" alt="Photo of {{item.name}}">-->
<div class="info row" ng-repeat="error in item.errors">
<div class="col s12">
<div class="row">
<div class="col s2 push10"><p class="type_message">Error Type:</p></div>
<div class="col s10 pull2">
<p >{{error.type}}</p>
</div>
</div>
</div>
<div class="col s12">
<div class="row">
<div class="col s2 push10">
<p class="type_message"> Error Message:</p>
</div>
<div class="col s10 pull2"><p>{{error.message}}</hp></div>
</div>
</div>
<!-- <h3>{{item.gender}}</h3>-->
</div>
</a>
</li>
,然後我用這個代碼,閱讀它的另一面
<section class="chatinfo">
<div class="chat cf" ng-model="records">
<a href="#/details/{{prevItem}}" class="btn btn-left"><</a>
<a href="#/details/{{nextItem}}" class="btn btn-right">></a>
<h1>{{records[whichItem].errors.type}}</h1>
<div class="info">
<h3></h3>
<img ng-src="images/{{records[whichItem].shortname}}_tn.jpg" alt="Photo of {{records[whichItem].name}}">
<div class="bio"></div>
</div>
</div>
<a href="index.html">« Back to search</a>
</section>
我的問題,我不工作我不知道爲什麼那是我的JSON數據
[{
"errors": [{
"type": "ActionView::Template::Error",
"message": "undefined method `average_price' for nil:NilClass",
"backtrace": [{
"file": "[PROJECT_ROOT]/app/views/quotes/show.html.haml",
"line": 1,
"function": "_app_views_quotes_show_html_haml___1123891298168566182_70087807002600"
}]
}]}]
我的問題是在這裏
<section class="chatinfo">
<div class="chat cf" ng-model="records">
<a href="#/details/{{prevItem}}" class="btn btn-left"><</a>
<a href="#/details/{{nextItem}}" class="btn btn-right">></a>
<h1>{{records[whichItem].errors.type}}</h1>
<div class="info">
<h3></h3>
<div class="bio"></div>
</div>
</div>
<a href="index.html">« Back to search</a>
</section>
我不能讀取數據