2016-08-11 2 views
1

UI 라우팅 설정에 게시 된 기사를 기반으로 간단한 예제를 설정했습니다.AngularJs UI 라우팅을위한 State.go

$state.go()을 사용하여 자식 중첩 상태에서 형제 상태로 명시 적으로 탐색하도록 테스트를 수정했습니다. 내가 뭘 잘못하고 있는거야? Error resolving State. Could not resolve .paragraph from state home.list

 $stateProvider 
 
      
 
      // HOME STATES AND NESTED VIEWS ======================================== 
 
      .state('home', { 
 
       url: '/home', 
 
       templateUrl: 'partial-home.html' 
 
      }) 
 
      
 
      // nested list with custom controller 
 
      .state('home.list', { 
 
       url: '/list', 
 
       templateUrl: 'partial-home-list.html', 
 
       controller: function($scope,$state) { 
 
        $scope.dogs = ['Bernese', 'Husky', 'Goldendoodle']; 
 
        $scope.navigateToNextState = function() { 
 
          $state.go('.paragraph'); 
 
         }; 
 
       } 
 
      }) 
 
      
 
      // nested list with just some random string data 
 
      .state('home.paragraph', { 
 
       url: '/paragraph', 
 
       template: 'I could sure use a drink right now.' 
 
      })

http://plnkr.co/edit/Nae6xz9qcBp3IRYi0wcD?p=preview

답변

0

컨트롤러는 다음과 같이 조정되어야한다 :

controller: function($scope, $state) { 
    $scope.dogs = ['Bernese', 'Husky', 'Goldendoodle']; 
    $scope.navigateToNextState = function() { 
     $state.go('^.paragraph'); 
    }; 
} 

나는 아래 오류가 계속우리는 함수 매개 변수 중 하나로 $state이 필요합니다. 그리고 우리는 아이에있다, 그래서 우리는 에 대한 검사 우리의 부모

의 또 다른 아이를 물어 (대신 '.paragraph'의) '^.paragraph'를 사용할 필요가 working fixed version here