我对 Angular 相当陌生,我正在尝试使用 Angular Wizard。
https://github.com/mgonto/angular-wizard
我的代码在 plunker 中,并且向导正在运行。但是,我在调用验证函数时遇到问题。我猜我在某个地方超出了范围。我将验证函数设置为返回 false,但我仍在继续下一步。
但是,正在调用正在完成向导的函数。
HTML
<wz-step title="Starting" canexit="exitValidation">
<h1>This is the first step</h1>
<p>Here you can use whatever you want. You can use other directives, binding, etc.</p>
<input type="submit" wz-next="" value="Continue" />
</wz-step>
<wz-step title="Continuing" canenter="enterValidation">
<h1>Continuing</h1>
<p>You have continued here!</p>
<input type="submit" wz-next="" value="Go on" />
</wz-step>
JS
var app = angular.module('registration', ['mgo-angular-wizard']);
app.controller('WizardController', ['$scope', 'WizardHandler',
function($scope, WizardHandler) {
$scope.finishedWizard = function() {
alert('Completed!');
};
$scope.enterValidation = function() {
alert('entering validation');
return false;
};
$scope.exitValidation = function() {
alert('exiting validation');
return false;
};
}
]);
http://plnkr.co/edit/QR9mpXH67ErhUzAKmN4c?p=preview
这个问题与下面的问题不同,因为步骤验证是在提问后添加的。
I'm trying to get form validations to work with an Angular Wizard
最佳答案
如果您使用的是最新版本的 Angular 向导(0.5.5),它就可以工作。旧版本中可能存在错误。这是一个正在工作的 Plunker
http://plnkr.co/edit/QR9mpXH67ErhUzAKmN4c?p=preview
这是网址
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-wizard/0.5.5/angular-wizard.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-wizard/0.5.5/angular-wizard.css" />
关于javascript - 未调用 Angular-Wizard 验证函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29736857/