Ui-router: going to a parameter that is not in the url?

There is a problem with passing in a parameter that is not a parameter in the URL.

I basically see the following click event

let stateParams = {
    id: event.info.id,
    info: event.info
};

this.$state.go('home.showinfo', stateParams);

I checked double in stateParams containing the identifier as well as the info object.

Then I have the following setting in state

.state('home.showinfo', {
    url: 'info/info/:id',
    resolve: {
        info: function($stateParams){
            return $stateParams.info;
        }
    },
    params: {
        info: null
    }

In my controller, I check the value of $ stateparams and I see id (also the url contains the ID), but the info object is null. Its always null. I just want to have access to it in the controller. Also "this.info" is also null.

I set a breakpoint in resole and the information is null.

I tried to remove params: {} above and still nothing.

Any ideas what I'm doing wrong?

Thanks in advance.

+4
1

, . , :

<a ui-sref="home.showinfo({id:1, info:'hi'})">
<a ui-sref="home.showinfo({id:2, info:'bye'})">

, :

.state('home.showinfo', {
    url: 'info/info/:id',
    templateUrl: 'showinfo.tpl.html',
    resolve: {
        info: function($stateParams){
            return $stateParams.info;
        }
    },
    params: {
        info: null
    }
})

+4

Source: https://habr.com/ru/post/1651030/


All Articles