我正在做一个长角度的表格。我想知道是否可以将其分解为许多不同的视图,并在主视图中分别引用它们。
<div class="container">
<div class="row" id="part1">
<div class="col-md-12">First Section</div>
</div>
<div class="row" id="part2">
<div class="col-md-12">Second Section</div>
</div>
<div class="row" id="part3">
<div class="col-md-12">Third Section</div>
</div>
...
</div>
Since my file is too long, is there a way using angular to have each section in a separate file and reference each of them in the main file? For example:
<div class="container>
"import section 1"
"import section 2"
"import section 3"
</div>
Thanks.
答案 0 :(得分:3)
创建局部视图(组件);
使用Angular CLI转到powershell / comand line / etc
;
第1步
ng g c import-section-1
ng g c import-section-2
ng g c import-section-3
将在app
文件夹下创建3个文件夹(这意味着您将拥有3个新组件);
第二步
根据需要编辑组件,然后引用所需的组件;
<div class="container>
<app-import-section-1></app-import-section-1>
<app-import-section-2></app-import-section-2>
<app-import-section-3></app-import-section-3>
</div>
答案 1 :(得分:2)
您还可以使用@shadowFoOrm提出的技术,然后将表单分成如下所示的选项卡:
您可以在此处找到此代码:https://github.com/DeborahK/Angular-Routing/tree/master/APM-Final