default inactive state for ui-router-extras

纵然是瞬间 提交于 2019-12-23 02:16:10

问题


I am using ui-router-extras to support parallel state for modal windows. When an modal window is open, the "home" state become inactive, but is still visible in the background. This allows me to have deep link for each modal windows.

However, I am having trouble figure out a good way to set the "default" inactive state to "home" if an user come through a modal window link.

I currently define my states like this:

$stateProvider
.state('signup', {
    url: '/signup',
    onEnter: function($modal) {
        $modal.open({
            templateUrl: 'singup.html',
            size: 'large',
            controller: 'SignUpController'
        });
    }
})

回答1:


You only posted one state definition! I tried to get the same working and finally figured it out. If you found a solution could you post it? If not please provide more details

Maybe my solution will help

angular.module('xbmcremoteApp')
    .config(function ($stateProvider,$stickyStateProvider) {
        $stickyStateProvider.enableDebug(true);
        $stateProvider
            .state('movies', {
                abstract: true,
                url: '/movies',
                templateUrl: 'app/movies/movies.html',
                controller: 'MoviesCtrl'
            }).state('movies.gallery', {
                url: '',
                templateUrl: 'app/movies/movies-gallery/movies-gallery.html',
                controller: 'MoviesGalleryCtrl',
                sticky:true
            }).state('movies.gallery.details', {
                url: '/:id',
                onEnter: ['$stateParams', '$state', '$modal', '$resource', function ($stateParams, $previousState, $modal, $resource) {
                    $modal.open({
                        templateUrl: 'app/movies/movies-gallery/myModalContent.html',
                        resolve: {
                            id: function () {
                                $stateParams.id
                            }
                        },
                        size:'lg',
                        controller: 'ModalInstanceCtrl'
                    }).result.then(function () {

                                return  $previousState.go("movies.gallery");

                        });
                }]
            });
    });



回答2:


check out ui-router-extras release 0.0.12 and above. I've added support for default substates in DSR. See this github issue for details:

https://github.com/christopherthielen/ui-router-extras/issues/150

And read the updated API docs here: http://christopherthielen.github.io/ui-router-extras/#/dsr

var myState = {
    name: 'foo',
    url: '/foo/:fooID/:barID',
    template: '<div></div>,
    controller: 'fooCtrl',
    deepStateRedirect: {
        default: { state: "foo.bar.baz.defaultSubState", params: { defaultStateParam1: "99" } }
    }
}


来源:https://stackoverflow.com/questions/25543128/default-inactive-state-for-ui-router-extras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!