Reputation: 163
templates.js this is controller file
.controller('TemplatesDetailsCtrl', ['$scope', '$routeParams', '$http', '$filter', function($scope, $routeParams, $http, $filter){
var templateId = $routeParams.templateId;
$http.get('json/templates.json')
.then(function(response){
$scope.templates = $filter('filter')(response , function(d){
return d.id == templateId
})[0];
$scope.mainImage = $scope.template.images[0].name;
});
}]);
template-details.html
<img class="img-full" src="img/{{mainImage}}">
Upvotes: 1
Views: 49
Reputation: 222582
As the error says, filter needs to get array as an input, but you are passing an object, try response.data
$scope.templates = $filter('filter')(response.data , function(d){
return d.id == templateId
})[0];
Upvotes: 1