在ui-router中更改子状态的可选参数时,停止加载父状态控制器

时间:2014-05-22 10:38:12

标签: angularjs angular-ui-router

我在Angular JS的UI路由器服务中面临一个问题。在加载子状态时,使用不同的可选参数使我的父状态的控制器加载。我不想要这个,因为它再次调用我的菜单和标题部分。

请参阅下面的代码:

    angular.module('tmeModule', ['tmeModule.controllers','tmeModule.services','tmeModule.directives','tmeModule.filters','ui.router','ngAnimate']).config(function($stateProvider, $urlRouterProvider,$locationProvider) {
    $urlRouterProvider.otherwise('/welcome');
    $stateProvider.
    state("welcome",{url:'/welcome',
        views:{
            "initload@": {templateUrl:"partials/welcome.html"}
        }
    ,authenticated:true}).
    state("welcome.profile",{url:'',
        views:{
            "profile": {templateUrl:"partials/profile.html"}
        },
    authenticated:true}).
    state("welcome.links",{url:'',
        views:{
            "profile": {templateUrl:"partials/profile.html"},
            "implinks": {templateUrl:"partials/implinks.html"}
        },
    authenticated:true}).
    state("welcome.dealClosed",{url:'',
        views:{
            "profile":{templateUrl:"partials/profile.html"},
            "implinks":{templateUrl:"partials/dealClosed.html"}
        },
    authenticated:true}).
    state("appHome", {
        url:'^/appHome?srchparam&srchWhich',
        views : {
            "initload@" : {
                templateUrl: "partials/appHome.html", 
                resolve:{
                    returnState:function($stateParams){
                        return {stateParam:$stateParams.srchparam,whichParam:$stateParams.srchWhich};
                    }
                },
                controller:"mktgPageController",
                onEnter: function(){
                    $scope.$new;
                },
                onExit: function(){
                    $scope.$destroy;
                }
            },
            "pageload@appHome" : {templateUrl: "partials/mktgHome.html"}
        }, 
    authenticated:true}).
    state("appHome.hotData",{url:'^/hotData?srchparam&srchWhich',
        views:{
            "pageload@appHome": {
                templateUrl:"partials/hotData.html"
            }
        },
    authenticated:true}).
    state("appHome.profile",{url:'',
        views:{
            "profile": {templateUrl:"partials/profile.html"}
        },
    authenticated:true}).
    state("appHome.links",{url:'',
        views:{
            "profile": {templateUrl:"partials/profile.html"},
            "implinks": {templateUrl:"partials/implinks.html"}
        },
    authenticated:true}).
    state("appHome.dealClosed",{url:'',
        views:{
            "profile":{templateUrl:"partials/profile.html"},
            "implinks":{templateUrl:"partials/dealClosed.html"}
        },
    authenticated:true}).
    state("notAuthorised", {url:'/notAuthorised',
        views:{
            "initload": {templateUrl:"partials/notAuthorised.html"}
        }
    ,authenticated:false});
    $locationProvider.html5Mode(true);
}).run(function($location,$rootScope,$stateParams){
    $rootScope.$on('$locationChangeStart', function (event,newUrl,oldUrl) {
        if(USERID   ==  '') {
            $location.url('/notAuthorised');
        } else {
            $rootScope.userid   =   USERID;
            $rootScope.oldPath  =   $location.url();
        }
    });
});

在调用我的hotdata状态时,我的父状态控制器自己调用。 请提出一些解决方案。

0 个答案:

没有答案