Search Posts

Category: routeparams

unable to view data redirected using $routeParams in angular

i have some data in the json format and want to view it in my html page, i used $routeParams for this, but the data cant be fetched from the json file. I created a controller like this: angular.module(‘app.controllers’, [ ‘app.directives’ ]) .controller(‘PostController’, [‘$scope’, ‘$http’, function ($scope, $http){ $http.get(‘data/posts.json’).then(function (data) { $scope.posts =; }); }]) .controller(‘SinglePostController’, [‘$scope’, ‘$http’, ‘$routeParams’, function($scope, $http, $routeParams) { $http.get(‘data/posts.json’).then(function (data){ $ = data[$]; }); }]); and the configuration is: […]