Я новичок в angularjs и использую версию 1.5.8 (я не могу обновить). Я пытаюсь использовать ng-repeat с
angular wizard на основе этого примера. Однако мои шаги по вопросам ng-repeat="question in vm.questions"
не повторяются. Ниже мой код. Пожалуйста, совет.
html
<form class="login-form idoquestion" name="idForm" id="idForm" novalidate ng-controller="iCtrl as vm">
<wizard hide-indicators="true" indicators-position="top">
<wz-step wz-title="Starting">
<h3 class="form-title">Begin</h3><br />
<div class="form-actions" style="padding-bottom: 55px">
<div class="pull-right" style="padding-top: 10px;">
<button type="submit" wz-next ng-disabled="!vm.disableNext" class="btn blue"> Next </button>
</div>
</div>
</wz-step>
<wz-step wz-title="Question" ng-repeat="question in vm.questions">
<h3 class="form-title">Question {{$index}}</h3>
<input type="radio" name="questionName" ng-value="question.answers" ng-model="vm.selectedAnswers[$index]" />
<label>{{ question.questionName }}</label>
<div class="pull-right" style="padding-top: 10px;">
<button type="submit" wz-next class="btn blue"> Next </button>
</div>
</wz-step>
<wz-step wz-title="More steps">
<span>Finish</span><br /><br />
<div class="form-actions" style="padding-bottom: 55px">
<div class="pull-right" style="padding-top: 10px;">
<button type="submit" wz-next class="btn blue" ng-click="vm.finishWizard()"> Exit </button>
</div>
</div>
</wz-step>
</wizard>
</form>
контроллер
(function () {
'use strict';
angular
.module('app')
.controller('iCtrl', iCtrl);
iCtrl.$inject = ['$scope', '$window', '$location', '$routeParams', 'modalService', 'userSession'];
function iCtrl($scope, $window, $location, $routeParams, modalService, userSession) {
var vm = this;
vm.questions = [];
vm.answers = [];
vm.selectedAnswers = [];
vm.disableNext = true;
init();
function getQuestions() {
var q1 = {
questionName: 'At which of the following addresses have you lived?',
answers: ['4344 BACKTRAIL DR', '113 BIRCH DR', '5015 B U BOWMAN DR', 'None of the above']
}
var q2 = {
questionName: 'What is the approximate square footage of the property at 222333 PEACHTREE PLACE?',
answers: ['1,000 or less', '1,001 - 1,500', '1,501 - 2,000', 'None of the above']
}
var q3 = {
questionName: 'At From whom did you purchase the property at 222333 PEACHTREE PLACE?',
answers: ['4344 BACKTRAIL DR', '113 BIRCH DR', '5015 B U BOWMAN DR', 'None of the above']
}
vm.questions.push(q1);
vm.questions.push(q2);
vm.questions.push(q3);
vm.selectedAnswers = new Array(vm.questions.length);
}
vm.finishWizard = function finishWizard() {
console.log('Wizard finished!');
}
function init() {
getQuestions();
}
}
})();