Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular-ui-router state.transitionTo routes to an empty:id (/users//)

where It should route to /users/me/ and Instead it routes to /users// if I manually write the /users/me/ url or use a link to move there, everything works fine. but transitionTo doesn't Do what I expect and I can't figure out why.

In my code I have:

$state.transitionTo('users.me');

where in my routes(states) config I have:

state('users', {
            abstract:true,

            templateUrl: '/path/to/template.html',

            access: { isPrivate: 0 },
            resolve: {
           ...a resolve block..



    }).state('users.me',{
            url: '/users/:id/',
            controller: 'userCtrl',
            access: { isPrivate: 0 },
            views:{
                'userView':{
                    templateUrl:'/path/to/template.html'',
                    controller:'userCtrl',

                },
                'view1':{
                    templateUrl:'/path/to/template.html'',
                    controller:'anotherCtrl',

                },
                'view2':{
                    templateUrl:'/path/to/template.html'',
                    controller:'anotherCtrl',

                },
                'view3':{
                    templateUrl:'/path/to/template.html'',
                    controller:'anotherCtrl',

                },
                'view4':{
                    templateUrl:'/path/to/template.html',
                    controller:'anotherCtrl'
                }
            }

I'll be glad for help with this

like image 972
alonisser Avatar asked Dec 01 '22 20:12

alonisser


1 Answers

Make sure you provide an id.

$state.transitionTo('users.me', {'id': 'me'});

This should make it work, but you should be using the go() method as transitionTo is a low-level function since 0.2.0.

$state.go('users.me', {'id': 'me'});

Be sure to read the method's documentation.

like image 164
Phil Thomas Avatar answered Dec 04 '22 09:12

Phil Thomas