.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"}
);
}]
}
})
;
}])
基本上我想要加载基于一个布尔值的另一个部分。有人可以指导我通过这吗?很新的角 !
试试这个,可能工作︰
.config(["$routeProvider", 'partial', 'contentUrl', 'appContext', function ($routeProvider, partial, contentUrl, appContext) {
$routeProvider
.when('/notifications', {
templateUrl: function (){
if (something) {
return partial('popup.html');
}
else {
return partial('popup2.html');
}
},
controller: 'popUpCtrl',
resolve: {
notifications: ['$http', function($http) {
if (something) {
return $http.post(
appContext('ViewAllNotifications.json'),
{"categoryGroupType":"ROLB","isArchived":"N","channelTypeCode":"101","limit":"20","page":"0","customerType":"A"}
);
}
else {
return $http.post(
appContext('ViewAllNotifications2.json'),
{"categoryGroupType":"ROLB","isArchived":"N","channelTypeCode":"101","limit":"20","page":"0","customerType":"A"}
);
}
}]
}
}
;
}])