2015-02-06 4 views
0

AngularJS 상태를 사용하여 중첩 된 양식에서 다음 단추를 만들려고합니다. 같이 여기 내 설정은 다음과 같습니다AngularJS 상태 다음 단추

.config(function($stateProvider, $urlRouterProvider) { 

$stateProvider 
    .state('step', { 
     url: '/step', 
     templateUrl: 'form.html', 
     count: '0', 
     controller: 'formController' 
    }) 
    .state('step.1', { 
     url: '/1', 
     count: '1', 
     templateUrl: 'form-1.html' 
    }) 
    .state('step.2', { 
     url: '/2', 
     count: '2', 
     templateUrl: 'form-2.html' 
    }) 
    .state('step.3', { 
     url: '/3', 
     count: '3', 
     templateUrl: 'form-3.html' 
    }) 
    .state('step.4', { 
     url: '/4', 
     count: '4', 
     templateUrl: 'form-4.html' 
    }); 
    $urlRouterProvider.otherwise('/step/1'); 
}) 

은 내가 NG 클릭 기능을 사용하고있는 상태 사이를 이동하려면 :

$scope.nextStep = $state.current.count; 

$scope.nextStepCount = function() { 
    $scope.count = $scope.nextStep + 1; 
    $state.go('step.' + $scope.count); 
} 

내가 그것을 단계 "의 현재 경로를 변경 다음 버튼을 클릭합니다. 1 "에서"step.11 "로 변경됩니다.

+1

문자열의 병합이 아닌 숫자 또한이 일어나고있는 것입니다. – Chris

답변

0

감사 JMK,이 마법처럼 작동하는 것 같다 :

$scope.nextStepCount = function() { 
    $scope.count = parseInt($state.current.count) + 1; 
    $state.go('step.' + $scope.count); 
} 
0

당신은 대체 할 수 :

$scope.count = $scope.nextStep + 1; 

으로 :

$scope.count = parseInt($scope.nextStep) + 1; 

자바 스크립트가되도록 문자열의 마지막에 1을 ​​추가하는 문자열로 넥스트 스텝을 치료한다.