I need to pass id from project/id to CommentCtrl, when I try to console.log($routeParams.id) it return undefined... Anyone can find what wrong with my code?
.config(function($routeProvider) {
$routeProvider.
when('/project/:id', {
controller: 'CommentsCtrl'
}).
otherwise({
redirectTo: '/'
});
})
.controller('CommentsCtrl',function($scope,$http,$routeParams){
$scope.comments = [];
$scope.param = $routeParams.id;
});
Update:
In html I just have module , CommentsCtrl and <div ng-view></div> inside CommentsCtrl like this:
<div ng-controller="CommentsCtrl">
<div ng-view></div>
</div>
console.log($routeParams)?ng-controller?controller: 'CommentsCtrl', you're doubling it