这对你来说非常容易。我有一个部分html中的两个视图(列表视图和网格视图),只需点击一下按钮即可通过ng-include注入。像这样:
<div class = "bar">
<h1>Contacts</h1>
<a href="#" class="list-icon" ng-class="{active: layout == 'list'}" ng-click="layout = 'list'"></a>
<a href="#" class="grid-icon" ng-class="{active: layout == 'grid'}" ng-click="layout = 'grid'"></a>
</div>
<div ng-show="layout == 'list'" class="list">
//ng-include for the list page is here
</div>
<div ng-show="layout == 'grid'" class="grid">
//ng-include for the grid page is here
</div>
如何启动其中一个观点?例如网格。我想这是用ng-init完成的。但我无法弄清楚
谢谢!
答案 0 :(得分:1)
您可以使用ng-init或在控制器变量声明中初始化变量: