角度离子 - 表单提交按钮不在表单标签内

时间:2016-12-23 18:25:33

标签: angularjs forms ionic-framework submit

我正在使用一个名为floating-tabs.js的库,它用于创建浮动导航按钮:这是布局的示例

<floating-tabs>
     //this is my button
     <floating-tabs-item icon="ion-android-arrow-dropright-circle" click="goNext(data)"></floating-tabs-item>
</floating-tabs>

<ion-content>
    <form name=“formName” ng-submit="goNext(data)">
        ***form stuff
    </form>
</ion-content>

如何在表格标签内没有我的按钮

的情况下提交/验证表格

谢谢你们

1 个答案:

答案 0 :(得分:0)

这里我使用简单的更改密码表单。

<form name="changepasswordform"  novalidate>                                   
  <input type="password" placeholder="New Password" class="reset-inputs"  name="newpassword" ng-keyup="compare()"  ng-model="changePassword.newpassword" maxlength="10"  required/> 
  <span style="color:red" ng-show="submitted && changepasswordform.newpassword.$error.required">Required</span>
 </form>
 <button type="button" class="reset-submit" ng-click="changepassword(changepasswordform.$valid,changePassword)">Change Password</button>  

它包含表格旁边的按钮

请使用控制器中的脚本

$scope.submitted = false;
$scope.changepassword = function(formValidStatus, formdata) {
if (!formValidStatus) {
    $scope.submitted = true;
} else {
    $scope.submitted = false;
}
}

在脚本中我检查表单是否有效如果表单无效我正在使用脚本中提交的变量显示错误消息。

这对我有用