0

각도 라우팅을 설정하려고합니다. <a ui-sref="classification.sequences.index">을 사용하여 경로를 탐색하면 올바른 위치로 라우트되고 http://localhost/classification/sequences/index으로 URL이 변경되고 출력에 0이 입력되고 5를 입력하고 콘솔에 2를 입력하십시오.각도 ui-router를 페이지로드시 라우팅하는 방법

하지만 수동으로 페이지를 새로 고치거나 처음부터이 URL로 이동해도 라우팅이 발생하지 않으며 콘솔에 아무 것도 출력되지 않습니다. 하지만 링크 버튼을 클릭하면 제대로 연결됩니다.

앵글이로드시 연결을 시도하거나 어딘가 어리석은 실수를 저 지르도록 설정해야 할 부분이 있습니까?

내 코드는 그것이 결코 시작 URL에 대해 평가하지 그래서 내가 설정 선 후 policyManagerApp.run()를 호출하지 않은 밝혀

policyManagerApp.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', 
    function($stateProvider, $urlRouterProvider, $locationProvider) { 

     // Activates HTML5 History API for modern browsers and sets the hashbang 
     // for legacy browsers 
     $locationProvider.html5Mode(true).hashPrefix('!'); 

     $urlRouterProvider.when("", "/classification/index"); 
     $urlRouterProvider.when("/", "/classification/index"); 

     // For any unmatched url, send to /classification/index 
     $urlRouterProvider.otherwise("/classification/index"); 

     $stateProvider 
      .state('classification', { 
       url: '/classification', 
       abstract: true, 
       template: '<ui-view/>', 
       onEnter: function() { 
        console.log("enter 0"); 
       } 
      }) 
      .state('classification.index', { 
       url: '/index', 
       templateUrl: '/html/partials/classification/index.html', 
       controller: 'PolicyManagerCtrl', 
       data: { 
        ncyBreadcrumbLabel: 'Classification' 
       }, 
       onEnter: function() { 
        console.log("enter 1"); 
       } 
      }) 
      .state('classification.sequences', { 
       url: '/sequences', 
       abstract: true, 
       template: '<ui-view/>', 
       onEnter: function() { 
        console.log("enter 5"); 
       } 
      }) 
      .state('classification.sequences.index', { 
       url: '/index', 
       templateUrl: '/html/partials/classification/sequences/index.html', 
       data: { 
        ncyBreadcrumbLabel: 'Collection Sequences' 
       }, 
       onEnter: function() { 
        console.log("enter 2"); 
       } 
      }) 
      .state('classification.sequences.detail', { 
       url: '/:id', 
       templateUrl: '/html/partials/classification/sequences/detail.html', 
       controller: 'SequenceDetailCtrl', 
       data: { 
        ncyBreadcrumbParent: 'classification.sequences.index', 
        ncyBreadcrumbLabel: '{{sequence.name}}' 
       }, 
       onEnter: function() { 
        console.log("enter 3"); 
       } 
      }) 
     ; 
    } 
]); 

답변

0

below- 볼 수 있습니다.

관련 문제