AngularJS状态下一步按钮

AngularJS状态下一步按钮,angularjs,Angularjs,我正在尝试使用AngularJS状态以嵌套形式创建下一个按钮。以下是我的设置: .config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('step', { url: '/step', templateUrl: 'form.html', count: '0', controller: 'formController' }

我正在尝试使用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 click功能的状态之间导航,请执行以下操作:

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

$scope.nextStepCount = function() {
    $scope.count = $scope.nextStep + 1;
    $state.go('step.' + $scope.count);
}
单击“下一步”按钮时,它会将“步骤1”上的当前路线更改为“步骤11”。

您可以替换:

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


Javascript将nextStep视为一个字符串,因此在该字符串的末尾添加1。

谢谢JMK,这看起来很有魅力:

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

正在发生的是串接而不是数字相加。
$scope.nextStepCount = function() {
    $scope.count = parseInt($state.current.count) + 1;
    $state.go('step.' + $scope.count);
}