0

I am a newbie to angular js . Here in my project i want to pass multiple parameters in anchor tag . So that i will get multiple params in address bar too. I have tried this one but its not working at all.

 <a href="" ui-sref="edit_user({id:0,pid:'add-user'})">Add New user</a>

It is showing "http://localhost/Angular/#/edit-user/0",but i need to pass some more parameters. Above is the code. I want the url to be ""http://localhost/Angular/#/edit-user/0/add-user"," Here , am I doing anything wrong ? Please suggest me . Thank you.

3
  • could you please add edit_user state & please update your question with what additional parameter you wanted to set in edit-user page Commented Nov 4, 2016 at 7:54
  • These parameters must be also declared in ui-route config Commented Nov 4, 2016 at 7:54
  • see this. plnkr.co/edit/r2JhV4PcYpKJdBCwHIWS?p=preview Commented Nov 4, 2016 at 7:55

1 Answer 1

1

You can do that like :

$state.go('editUser', {id: 0, pid: 0});

 // or  In your view :

 <a ui-sref="editUser({id:0,pid:0})">Add New user</a>

In your config :

$stateProvider
.state('editUser', {
  url: '/edit-user?id&pid',
  views: {
    '': {
      templateUrl: 'users.html',
      controller: 'MainCtrl'

    },
  },
  params: {
    id: null,
    pid: null
  }
})
Sign up to request clarification or add additional context in comments.

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.