0

I am new to Angular.js ....Based on the id, the fullPostController gets the required data using $http, but how am I supposed to pass the postId to the controller?

 'use strict'; var myAPP = angular.module('myAPP', [ 'ngRoute' ]); myAPP.config(['$routeProvider', function ( $routeProvider ) { $routeProvider. when('/', { templateUrl: 'pages/home.html', controller: 'mainController' }). when('/post/:postId', { templateUrl: 'pages/full_post.html', controller: 'fullPostController' }). otherwise({ redirectTo: '/' }); }]); 

How do I pass the postId to fullPostController??

1 Answer 1

1

inject $routeParams in the controller, the post id is $routeParams.postId

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.