我有一个包含3个表单的html模板。我需要在另一个页面中重用该模板中的控制器和两个表单。我怎样才能做到这一点?
mainForm.htm
<form ng-show="activeTab == 'form1'" name="form1" id="form1">
<p> this is form1 </p>
</form>
<form ng-show="activeTab == 'form2'" name="form2" id="form2">
<p> this is form2 </p>
</form>
<form ng-show="activeTab == 'form3'" name="form3" id="form3">
<p> this is form3 </p>
</form>
subForm.htm
<div ng-include="mainForm.htm">
<p> need only form1 and form3 from mainForm.htm here</p>
</div>
答案 0 :(得分:1)
正如我在您的问题中所评论的,最好的方法是在单独的视图中创建每个表单,并根据需要创建ng-include
。
<强> form1.html 强>
<form method="POST" name="form1" id="form1">
<!-- your form code -->
</form>
(并为每个表格重复此示例)
<强> mainForm.html 强>
<div ng-show="activeTab == form1">
<div ng-include="form1.html"></div>
</div>
<!-- Each other form you want -->