AngularJS: v1.5.11
Im trying to display images from a JSON array.
Is this the proper way : $scope.mainImage = $scope.template.images[0].name;. This is the line in the error that it says cant read property of images.
My Controller in templates.js file:
.controller("TemplatesDetailsCtrl", ["$scope", "$routeParams", "$http", "$filter", function($scope, $routeParams, $http, $filter ){
var templateId = $routeParams.templateID;
$http.get("json/templates.json").success(function(data){
$scope.template = $filter("filter")(data, function(d){
return d.id == templateId;
})[0];
$scope.mainImage = $scope.template.images[0].name; //THIS IS LINE 30
});
}]);
I'm trying to display the very first image from the array. So my HTML is:
<img class="img-full" src="img/{{mainImage}}">
Ben trying a lot and not able to display the image. Im getting this error:

Please help.
$routeParams.templateIDreturn? What does$scope.templatereturn? What does data look like? you clearly aren't getting what you expect in$scope.templateso you need to dig in to find out whyconsole.log(templateId)right after i defined thevar templateIdand got the same error. I mis-spelled$routeParams.templateID. Changing it to$routeParams.templateIdworked. Thanks. I was trying this for a long time.