2
$stateProvider.state('state1', {
url:'/state1/:param1/and/{param2:.+}',
templateUrl: 'state1.html',
controller: 'State1Controller',
});
위와 같이 정규식을 사용하여 param2
을 필요로하려고합니다. 비어 있다면, 디폴트 상태는로드해야합니다 :각도 UI 라우터 - 매개 변수를 만드는 방법
$urlRouterProvider.otherwise("/");
$stateProvider.state('otherwise',{
url: '/',
templateUrl:'default.html'
});
을 이제 결과 :
state1/1/and/1
이 state1
로 이동합니다. 좋은.
state1/1/and
은 otherwise
입니다. 좋은.
그러나,
state1/1/and/
이없는 상태로 간다! 어느 상태도로드되지 않습니다. /
으로 리디렉션 중입니다. 뭐?!
매개 변수를 올바르게 작성하려면 어떻게해야합니까?
State1Controller에는 무엇이 있습니까? 콘솔에있는 모든 것? 'state1'에있는 어떤 소리가 날 수 있습니다. "어느 주가도로드되지 않는다"고 생각하게 만드는 이유는 무엇입니까? – adamdport
'state1.html'이로드되지 않았습니다. ui-view는 비어 있습니다. 나는 또한'State1Controller'에'console.log ('loaded')'를 넣었고 콘솔에 출력하지 않았다. 오류도 없습니다. – Shawn
예상대로 예상대로 작동합니다. http://plnkr.co/edit/XTDJ5FAHNh63RoECKwCQ?p=preview –