如何将单个动态生成的表单划分为angularJs中的多个页面,其中" required"验证??
答案 0 :(得分:1)
您将每个页面放在一个Div中,并将该div的可见性绑定到将存储当前页面的模型变量。这是Plunker http://plnkr.co/edit/ZU7h68iHaFK0k2zSfZhS?p=preview
<form name="myForm">
<h1>{{currentPage}}</h1>
<div ng-show="currentPage==1">
Page1<input type="text" ng-model="page1" ng-required="currentPage==1"/>
</div>
<div ng-show="currentPage==2">
Page2<input type="text" ng-model="page2" ng-required="currentPage==2"/>
</div>
<div ng-show="currentPage==3">
Page3<input type="text" ng-model="page3" ng-required="currentPage==3"/>
</div>
<input type="submit" value="Next" ng-click="NextPage()" ng-disabled="myForm.$invalid" />
</form>