angularJS 中的逻辑form

angularJS中可以针对form表单进行校验,例如

<form name="myForm">
    <input type="text" name="name" required/>
    <span ng-show="myForm.name.required">请输入名称</span>
</form>

如果有多个区域需要校验,可以使用逻辑指令ng-form

<form submit="save()">
    <div ng-form="form1">
        ...controls...
        <button ng-click="proceed()"
            ng-disabled="form1.$invalid">Proceed</button>
    </div>
    <div ng-form="form2">
        ...controls...
        <button type="submit"
            ng-disabled="form2.$invalid || form1.$invalid">Submit</button>
    </div>
</form>

相关推荐