基于布尔值在angularJS中路由

时间:2016-04-10 07:10:11

标签: javascript jquery angularjs

.config(["$routeProvider", 'partial', 'contentUrl', 'appContext', function ($routeProvider, partial, contentUrl, appContext) {
        $routeProvider
            .when('/notifications', {
                templateUrl: partial('popup.html'),
                controller: 'popUpCtrl',
                resolve: {
                    notifications: ['$http', function($http) {
                        return $http.post(
                            appContext('ViewAllNotifications.json'),
                            {"categoryGroupType":"ROLB","isArchived":"N","channelTypeCode":"101","limit":"20","page":"0","customerType":"A"}
                        );
                    }]
                }
            })
        ;
    }])

上面的代码完全正常。我想在此做一些基于条件的路由。我能做点什么吗?

.config(["$routeProvider", 'partial', 'contentUrl', 'appContext', function ($routeProvider, partial, contentUrl, appContext) {
        $routeProvider
            .when('/notifications',
                if(something){
                templateUrl: partial('popup.html'),
                controller: 'popUpCtrl',
                resolve: {
                    notifications: ['$http', function($http) {
                        return $http.post(
                            appContext('ViewAllNotifications.json'),
                            {"categoryGroupType":"ROLB","isArchived":"N","channelTypeCode":"101","limit":"20","page":"0","customerType":"A"}
                        );
                    }]
                }
            } 
            else{
                templateUrl: partial('popup2.html'),
                controller: 'popUpCtrl',
                resolve: {
                    notifications: ['$http', function($http) {
                        return $http.post(
                            appContext('ViewAllNotifications2.json'),
                            {"categoryGroupType":"ROLB","isArchived":"N","channelTypeCode":"101","limit":"20","page":"0","customerType":"A"}
                        );
                    }]
                }
            })
        ;
    }])

基本上我想基于布尔值加载另一个部分。有人可以指导我完成这个吗?我对角度很新。

0 个答案:

没有答案