我有这个离子页面:
<ion-view view-title="Sign up for business">
<ion-nav-bar class="bar-positive">
<ion-nav-back-button></ion-nav-back-button>
<ion-nav-buttons side="right">
<button class="button button-icon icon ion-android-done" ng-disabled="bizzSForm.$invalid" ng-click="submitBizzForm()"></button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content>
<form name="bizzSForm" class="css-form" ng-submit="submitSignUpForm()" novalidate>
<div class="list">
<label class="item item-input">
<i class="icon ion-person placeholder-icon"></i>
<input type="text" placeholder="Your business or organization name" name="name" ng-model="bizzFormData.name" ng-minlength="3" ng-maxlength="50" required>
</label>
<div ng-show="bizzSForm.$submitted || bizzSForm.name.$touched">
<span ng-show="bizzSForm.name.$error.required" class="form-err-blk"><i class="ion-close-round"></i> Tell us your business or organization name.</span>
</div>
我有这个控制器代码:
$scope.submitBizzForm = function() {
if($scope.bizzSForm.$valid) {
$scope.submitSignUpForm();
}
}
此处$scope.bizzSForm
显示undefined
答案 0 :(得分:0)
您可以在ngSubmit
回调中传递bizzSForm,并按原样使用:
HTML 的
<form name="bizzSForm" class="css-form" ng-submit="submitSignUpForm(bizzSForm)" novalidate>
<!-- content -->
</form>
的Javascript
$scope.submitBizzForm = function(form) {
if(form.$valid) {
$scope.submitSignUpForm();
}
};