Я пытаюсь создать следующую кнопку во вложенной форме с использованием состояний AngularJS. Вот моя установка как:AngularJS state next button
.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');
})
Для перехода между состояниями я использую функцию нг-клик:
$scope.nextStep = $state.current.count;
$scope.nextStepCount = function() {
$scope.count = $scope.nextStep + 1;
$state.go('step.' + $scope.count);
}
Когда я нажимаю на кнопку Далее, она изменяет текущий маршрут на «шаг. 1 "до" step.11 ".
конкатенация строки, а не сложение чисел является то, что происходит. – Chris