2

I have a state as such:

.state('home.deletemsg', {
  views: {
  "contentworker@": {
    url: '/delete/:entityname/:id/:redirectstate',
    templateUrl: "Scripts/proteanapp/templates/delete.html",
    controller: 'deletectrl',
    controllerAs: 'del',
    authenticate: true
   }
}

Then in the controller I have:

return app.controller('deletectrl', ['$scope', '$rootScope', '$stateParams',  function ($scope, $rootScope, $stateParams) {
        debugger;
        // check for ui router error
        var del = this;
        del.entityname = $stateParams.entityname;
        del.entityid = $stateParams.id;
    }]);

Calling $state.go from a controller like :

$state.go('home.deletemsg', { 'entityname': cd.Customer.Name, 'id': cd.Customer.CustomerID }, { 'location': false, 'notify': true });

But the $stateParams is empty, I don't understand why it is empty. I have tried putting an params object into the state and also resolve.

$stateParams.entityname //undefined

$stateParams.id //undefined

1 Answer 1

3

url option should be present there on state definition directly, not inside views object of state. But even your controller should not have been called the way you have configured your state.

Code

.state('home.deletemsg', {
  //url should present here, rather than putting it inside `views`
  url: '/delete/:entityname/:id/:redirectstate',
  views: {
  "contentworker@": {
    templateUrl: "Scripts/proteanapp/templates/delete.html",
    controller: 'deletectrl',
    controllerAs: 'del',
    authenticate: true
   }
}
Sign up to request clarification or add additional context in comments.

2 Comments

damn it, you are right. I dont know how i missed that :)
No worries, that happens. Even your controller should have get called..I feel you are doing something else in you code

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.