簡體   English   中英

AngularJs向導驗證輸入字段找不到范圍

[英]AngularJs Wizard Validation Inputfield can't find scope

我是AngularJs的新手,我的代碼有問題。

目前,我的HTML看起來像:

<div class="wizardContainer">
<wizard on-finish="finishedWizard()">
    <wz-step title="1">
        <h1>Question 1</h1>
        <p>How old are you?</p>
        <form name="age_form" novalidate ng-submit="signupForm()">
            <fieldset>
                <input type="text" name="age" ng-model="user.age"
                       ng-minlength=1 required>

                <div class="error-container"
                     ng-show="age_form.age.$invalid && age_form.submitted">
                    <small class="error"
                           ng-show="age_form.age.$error.required">
                        Please fill in the field
                    </small>
                    <small class="error"
                           ng-show="age_form.age.$error.minlength">
                        Please fill in mininum 1 number
                    </small>
                </div>
                <button type="submit" class="btn btn-default full-width">go on</span></button>
            </fieldset>
        </form>
    </wz-step>
    <wz-step title="2">
        <h1>Question 2</h1>
        <p>How are you?</p>
    </wz-step>
</wizard>

我的控制器看起來像:

angular.module('ngBoilerplate.about', [
    'ui.router',
    'placeholders',
    'ui.bootstrap',
    'mgo-angular-wizard'
])

.config(function config($stateProvider) {
    $stateProvider.state('about', {
        url: '/about',
        views: {
            "main": {
                controller: 'AboutCtrl',
                templateUrl: 'about/about.tpl.html'
            }
        },
        data: { pageTitle: 'What is It?' }
    });
})

.controller('AboutCtrl', function AboutCtrl($scope) {

    $scope.user = {};

    $scope.submitted = false;

    $scope.signupForm = function() {
      if ($scope.age_form.$valid) {
          window.location="#/about";
      } else {
        $scope.age_form.submitted = true;
      }
    };
});

如果在向導的第一步中單擊“提交”按鈕,則會在控制台中顯示以下錯誤:$ scope.age_form未定義

有人可以幫我解決這個問題嗎?

非常感謝你的回答!

角度向導項目當前存在范圍問題。 我能夠在下面的帖子中解決它。

嘗試獲取表單驗證以與Angular向導一起使用
我正在嘗試通過Angular Wizard進行表單驗證

但是,這是一個臨時修復。 該項目肯定需要重新設計。

一切都與github上的這個問題有關。

步驟驗證?!
https://github.com/mgonto/angular-wizard/issues/41

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM