1

I need to pass the query string to templateUrl as html is generated by Django view in this case.

I am trying to pass parameters(itemId) to templateUrl in angularjs ui-router like the following:

    .state('MyApp.itemEdit',{
        url: '/items/:itemId',
        views: {
            'editItems@':{
                templateUrl: '/core/edit-item-tmpl?itemId',
                controller: 'EditItemCtrl as editItems'
            }
        }
    })

This is not working. Wanted to know whether this can be done as I am not able to find anything related to this in docs.

Thanks

1 Answer 1

4

You can get the itemId parameter if you used a function for templateUrl:

.state('MyApp.itemEdit',{
        url: '/items/:itemId',
        views: {
            'editItems@':{
                templateUrl: function(params){
                   return '/core/edit-item-tmpl?' + params.itemId;
                },
                controller: 'EditItemCtrl as editItems'
            }
        }
    })
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks this is what I was looking for.

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.