2016-04-10 10 views
0
.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"} 
         ); 
        }] 
       } 
      }) 
     ; 
    }]) 

このコードは上手く機能します。私はこれにいくつかの条件ベースのルーティングをしたい。私は何かのようにすることはできますか?ブール値に基づいたangularJSでのルーティング

.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

は働くかもしれない、これを試してみてください。

.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"} 
          ); 
         } 
        }] 
       } 
      } 
     ; 
    }]) 
+0

勤務の男を!ありがとう、トン:) –

関連する問題