Because you don't want to write complex forms validation, you find Ngmessages, simple, rude, and effective-just modify the HTML template.
Ionic ngmessages
1. Installation
install angular-messages --save
2. Add toIndex.html
<script src="lib/angular-messages/angular-messages.min.js"></script>
3. Actions in the template
such as input
class="item item-input"> <span class="input-label">Title</span> <input id="slug" type="text" name="title" placeholder="Write here" ng-model="posts.title" required ng-minlength="2" ng-maxlength="70"> </label>
Limit the length and required, in fact, there should be ng-messages, such as:
<div ng-messages="myForm.myField.$error" role="alert"> <div ng-message="required">You did not enter a field</div> <div ng-message="minlength, maxlength"> Your email must be between 5 and 100 characters long </div> </div>
However, I think the personal blog does not need to do so, and then straight down
class="button button-block button-positive" ng-click="create(postsForm)" ng-disabled="postsForm.$invalid" type="submit">发送 </button>
If the form is not valid, the Send button is not a point.
Ionic ngmessage Form Validation