Question

For the following code sample, the params does not seem to take affect. but if I put the param as part of url then it works fine. Both are supposed to be equivalent. However putting in params generates uncaught object exception. Where am I going wrong.

 $stateProvider.state('start', {
        params: ['lang'],
        views : {
            'navbar' : {
                templateUrl: function($stateParams) {
                    return '/static/html/' + $stateParams.lang +  '/navbar.html';
                }
            },
            'jumbotron' : {
                templateUrl: function($stateParams) {
                    return '/static/html/' + $stateParams.lang + '/jumbotron.html';
                }
            },
            'main_content' : {
                templateUrl: function ($stateParams) {
                    return '/static/html/' + $stateParams.lang + '/main_content.html';
                }
            }
        },
        url: '/'
    })
Was it helpful?

Solution

Try removing the url from your state. I was having this same issue and removing the url from the state fixed it for me. See second answer on this Stack Overflow question for an example: How to send and retrieve parameters using $state.go toParams and $stateParams?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top