0
角js中是否有任何方法或標記/指令在不使用ngClick和ngSubmit的情況下發送數據?如何在不使用ngClick和ngSubmit的情況下提交表單數據
因爲在這兩種方法中我們都必須明確地提到函數名。我想避免這種安全目的?
這是我的代碼:
<form name="userForm" novalidate>
<div class="col-md-2"></div>
<div class="col-md-8">
<h2 class="title-text">Get Quote</h2>
<div class="row"> </div>
<div class="form-group" ng-class="{ 'has-error' : userForm.name.$invalid && !userForm.name.$pristine }">
<label>Name:</label>
<input type="text" name="name" class="form-control" ng-model="formData.name" required>
<p ng-show="userForm.name.$invalid && !userForm.name.$pristine" class="help-block">name is required.</p>
</div>
<div class="form-group" ng-class="{ 'has-error' : userForm.email.$invalid && !userForm.email.$pristine }">
<label>Email</label>
<input type="email" name="email" class="form-control" ng-model="formData.email">
<p ng-show="userForm.email.$invalid && !userForm.email.$pristine" class="help-block">Enter a valid email.</p>
</div>
<div class="form-group" ng-class="{ 'has-error' : userForm.subject.$invalid && !userForm.subject.$pristine }">
<label>subject:</label>
<input type="text" name="subject" class="form-control" ng-model="formData.subject" ng-minlength="3" ng-maxlength="15">
<p ng-show="userForm.subject.$error.minlength" class="help-block">subject is too short.</p>
<p ng-show="userForm.subject.$error.maxlength" class="help-block">subject is too long.</p>
</div>
<div class="form-group" ng-class="{ 'has-error' : userForm.description.$invalid && !userForm.description.$pristine }">
<label>Description:</label>
<input type="text" name="description" class="form-control" ng-model="formData.description" ng-minlength="3" ng-maxlength="200">
<p ng-show="userForm.description.$error.minlength" class="help-block">description is too short.</p>
<p ng-show="userForm.description.$error.maxlength" class="help-block">description is too long.</p>
</div>
<button class="btn btn-primary btn-lg" id="btn-get-requirement" ng-disabled="userForm.$invalid">Get Quote</button>
</div>
<div class="col-md-2"></div>
</form>
我可以用id屬性在angularjs提交表單數據?或者有什麼方法?