I want to show the details of the image in which template Id is matched. For this, I use this code and get the error.
controller('TemplateDetailsCtrl',
['$scope', '$routeParams','$filter','$http',
function($scope, $routeParams, $http, $filter) {
var templateId = $routeParams.templateId;
$http.get('json/templates.json').then(function(response){
data = response.data
$scope.template = $filter('filter')(data, function(d){
return d.id == templateId;
})[0];
});
$scope.mainImage = $scope.template.images[0].name;
}]);
Error:
TypeError:
$http.get is not a function at new <anonymous> (templates.js:25) at Object.instantiate (angular.js:5137) at $controller (angular.js:11688) at Object.link (angular-route.js:1251) at angular.js:1365 at invokeLinkFn (angular.js:11235) at nodeLinkFn (angular.js:10554) at compositeLinkFn (angular.js:9801) at publicLinkFn (angular.js:9666) at lazyCompilation (angular.js:10080) "<div ng-view="" class="ng-scope">"