在angular中使用html模板's ng开关
Using html templates in angular's ng-switch
我正在制作一个随着用户点击而移动的"交互式菜单"。我想知道是否有一种方法可以在ng switch中包含html模板,由于每个"开关"中的所有逻辑都不同,因此会产生巨大的html文件。
<div class="content" ng-switch on="selection">
<div ng-switch-when="1" >
<h1>1</h1>
</div>
<div ng-switch-when="2">
<h1>2</h1>
</div>
</div>
使用ngInclude
:
<div class="content" ng-switch on="selection">
<div ng-switch-when="1" >
<ng-include src="'template1.html'"></ng-include>
</div>
<div ng-switch-when="2">
<ng-include src="'template2.html'"></ng-include>
</div>
</div>
注意:如果你正在硬编码路径,不要忘记使用双引号中的单引号。
您应该能够使用ng-include
指令:
<div class="content" ng-switch on="selection">
<ng-switch-when="1" ng-include="//TEMPLATE PATH">
<ng-switch-when="2" ng-include="//TEMPLATE 2 PATH">
</div>
**I used ng-Include this way.**
<!-- Main content -->
<div class="row">
<!-- right col -->
<section class="col-lg-12">
<ul class="nav nav-tabs responsive ui-tabbed" id="myTab">
<li class="active">
<a data-ng-click=' main.active.tab = "tab-1" '>Tab 1</a>
</li>
</ul>
<!-- end responsive tabs -->
<div class="tab-content ui-tabbed-contents responsive">
<div data-ng-switch = " main.active.tab ">
<div data-ng-switch-when='tab-1' >
<ng-include src="'tab-one.html'" ></ng-include>
</div>
</div>
</div>
</div>
<!-- end main tabs container -->
</section>
相关文章:
- AngularJS ng开关或类似的动态值工作
- AngularJs.使用ng重复和ng开关渲染表
- 在angular中使用html模板's ng开关
- 有条件的角度ng开关
- ng开关不工作
- 使用 ng 开关构建切换开关
- 如何与ng开关中的全局变量进行比较
- 当ng开关完成渲染时
- ng repeat内部的动态ng开关
- 使用ng开关进行ng重复:需要呼叫锚中的服务.怎样
- Angular JS:使用ng开关并检查文件是否存在
- AngularJS ng开关在<p>标签
- 如何在没有ng开关的情况下处理角ng显示中的if else情况
- ng开关未自动更新
- 如何使用ng开关来更好地验证
- AngularJs:编译ng开关时出错
- Angular js:Ng开关在Ng点击后没有更新
- 在禁用ng的情况下使用ng开关
- 将ng开关插入ng repeat内部时的角度误差
- ng开关与预期选项不匹配