I am making an application using AngularJS and want to be able to switch between "tabs" and swap back and forth different "partials" or html templates into a panel/container (using ngInclude
).
Here's my template, which is wrapped inside a ngView
.
<div class="row">
<div class="col-md-3">
<div class="list-group" data-fixed-sidebar data-nav-control>
<a href="#/analyze/option1" class="list-group-item" data-tab-route="/analyze/option1.*" >Analyze Option 1</a>
<a href="#/analyze/option2" class="list-group-item" data-tab-route="/analyze/option2.*">Analyze Option 2</a>
<a href="#/analyze/option3" class="list-group-item" data-tab-route="/analyze/option3.*">Analyze Option 3</a>
<a href="#/analyze/option4" class="list-group-item" data-tab-route="/analyze/option4.*">Analyze Option 4</a>
</div>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-body">
<div ng-include="child"></div>
</div>
</div>
</div>
</div>
The problem is, when I click on one of the links (for example, the first link which routes to #/analyze/option1
) it will reload my controller and lose track of it's current state. I am using $route
and $routeProvider
and would prefer a solution that keeps using this module.