0

I am using the $routeParams service. when i console_log($routeParams) the service in my controller i see in the console all the values.

However when i console log $routeParams.id i get undefined. ( when i console out $routeParams i see the parameters )

i am able to get the values only if i use timeout:

$timeout(function() { $scope.id = $routeParams.id; }, 100); 

any idea why that happens? its really weird and i think i am missing something.

2
  • can you post sample fiddler for the same. Commented Dec 15, 2015 at 10:23
  • 2
    Possible duplicate of stackoverflow.com/questions/17519937/…, the top answer provides a solution to this problem. Commented Dec 15, 2015 at 10:23

1 Answer 1

1

I found an alternative way:

$scope.$on('$routeChangeSuccess', function() { // $routeParams.id exists }); 
Sign up to request clarification or add additional context in comments.

1 Comment

You're the man!, this was properly doing my nuts in I might consider stateProvider tho

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.