1

in my stateProvider definition I have:

return function ( $stateProvider ) {
    return $stateProvider.state('welcomeCAReg', {
                                url:         '/myURL/:id',
                                templateUrl: 'hi.html',
                                controller:  'hiController'
                         })

and then, in the controller I want to read the :id param:

$locationProvider.html5Mode().enabled = true;
....
var paramValue = $location.search().id;

but the paramValue value is undefined, why ?

0

2 Answers 2

1

You should use $stateParams service:

function hiController($stateParams) {
    console.log( $stateParams.id )
}
Sign up to request clarification or add additional context in comments.

Comments

0

Ok, I ended up by using

$state.params['id'];

which works

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.