我正在创建一个Ionic应用程序,当我使用<时,我遇到了一些表单验证问题离子滚动> 标签。这是我的表格:
<form ng-show="!success" name="form" role="form" novalidate ng-submit="register()" show-validation>
<div class="list list-inset">
<label class="item item-input">
<input type="text" class="form-control" name="firstName" placeholder="Nome"
ng-model="registerAccount.firstName" ng-minlength=1 ng-maxlength=50 required maxlength="50">
</label>
<div ng-show="form.firstName.$dirty && form.firstName.$invalid" class="padding-top padding-left assertive">
<p class="help-block"
ng-show="form.firstName.$error.required">
some message
</p>
</div>
.
.
.
<label class="item item-input">
<input type="password" class="form-control" name="password" placeholder="Senha"
ng-model="registerAccount.password" ng-minlength=5 ng-maxlength=50 required>
</label>
<div ng-show="form.password.$dirty && form.password.$invalid" class="padding-top padding-left assertive">
<p class="help-block"
ng-show="form.password.$error.required">
some message
</p>
</div>
<label class="item item-input">
<input type="password" class="form-control" name="confirmPassword" placeholder="Repita a senha"
ng-model="confirmPassword" ng-minlength=5 ng-maxlength=50 required>
</label>
<div ng-show="form.confirmPassword.$dirty && form.confirmPassword.$invalid" class="padding-top padding-left assertive">
<p class="help-block"
ng-show="form.confirmPassword.$error.required">
some message
</p>
<p class="help-block"
ng-show="form.confirmPassword.$error.minlength">
Sua confirmação de senha precisa ter no mínimo 5 caracteres.
</p>
<p class="help-block"
ng-show="form.confirmPassword.$error.maxlength">
Sua confirmação de senha deve ser menor que 50 caracteres.
</p>
</div>
</div>
<div class="form-button">
<button type="submit" class="button button-block button-balanced">Criar conta</button>
</small>
</div>
</form>
当没有Ionic标签时,此表单正常工作,但是,当我在表单标签内部或外部添加离子滚动标记时,验证失败,说密码和确认密码是不同。我应该使用特定的Ionic标签吗?哪个可能是我应该使用的标签?
答案 0 :(得分:0)
问题是因为一些离子组件使用子范围,这种范围"creates an 'isolate' scope that does not prototypically inherit." 我使用建议的最佳使用方法解决了我的问题&#34;。&#34; (点)我的模特。所以我改变了:
<input type="password" ng-model="confirmPassword" required>
到
<input type="password" ng-model="something.confirmPassword" required>