Angular UI-Router passing data between states with go function does not work

后端 未结 2 1088
慢半拍i
慢半拍i 2020-12-05 15:22

I just started learning angularjs and I am using angular-ui-router. I am trying to send data from one state to another using $state.go but I have no success. He

2条回答
  •  攒了一身酷
    2020-12-05 16:07

    When you say: $state.go('private.visits', { name : "Object"});

    You're not passing data to the private.visits state, but rather you're setting a parameter to the private.visits state, which doesn't even support parameters as you have not defined parameters for it in the state config. If you want to share data between states use a service, or if your states have a parent-child relationship then the child state will have access to the parent states data. Seeing as how you don't want the data to sow up in your URLs, I would use a service (getters/setters) to achieve this.

提交回复
热议问题