javascript - 未调用 Angular-Wizard 验证函数

标签 javascript angularjs angularjs-scope

我对 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/

相关文章:

javascript - Aurelia - repeat.for 按值转换器排序在 IE 11 中失败

javascript - 无法在 Angular 中显示 Google Charts

angularjs - AngularJS 中的方法重载\重写

javascript - 使用 AngularJS 在表中选择复选框

javascript - 通过另一个属性指令设置属性指令导致双重绑定(bind)

javascript - datejs在javascript中覆盖日期

javascript - 查询首先有效,但查找无效

javascript - 在页面加载时增加 DIV?

javascript - 在 livequery 中初始化用户类

javascript - 将焦点放在 ng-click 调用的函数中的 'this' 元素上