2016-10-10 6 views
0

내 탭 중 하나에 대해 다음 UI 라우터 상태를 가지고 :각도 UI 라우터 숨겨진 매개 변수

$stateProvider 
     .state('systems', { 
      url: '/Tabs/System', 
      templateUrl: function ($stateParams) { 
       return ('/Tabs/Systems/IndexNoLayout') + (typeof $stateParams.CustomerName === 'undefined' ? '' : '/' + $stateParams.CustomerName); 
      }, 
      params: { CustomerName: '' }, 
      controller: 'systemCtrl' 
     }); 

해당 탭에 대한 링크 :

<a ui-sref="systems({CustomerName: 'dummyCustomer'})"> 
    Save state 
</a> 

과 MVC 컨트롤러 옵션 매개 변수 :이 매개 변수는 다음 면도기를 사용하여 내 MVC보기에 사용되는

public ActionResult IndexNoLayout(string CustomerName){...} 

. 위의 코드가 작동합니다. 내가 쉽게 각도보기에 대해 $ stateChangeStart에 $ templateCache을 삭제할 수

templateUrl: '/Tabs/Systems/IndexNoLayout' 

이 방법 :

$templateCache.remove(fromState.templateUrl); 

이 가능은 할 그러나 나는 다음과 같이 내 templateUrl 정의를 가지고 싶다? 따라서

답변

0

This SO post helped me solve my problem.

내 솔루션 :

$stateProvider 
     .state('systems', { 
      url: '/Tabs/System',    
      templateUrl:'/Tabs/Systems/IndexNoLayout', 
      params: { CustomerName: '' }, 
      controller: 'systemCtrl'    
     }); 

내 $의 stateChangeStart에서 :

$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {    

     if (toState.name == "systems") { 
      toState.templateUrl = ('/Tabs/Systems/IndexNoLayout' + (typeof toParams.CustomerName === 'undefined' ? '' : '/' + toParams.CustomerName)); 
     } 

     $templateCache.remove(toState.templateUrl); ...}); 
관련 문제