In my HTML page, there are three tabs each having unique controller bonded to it as following:
MainHTML (app.pages.managing.html):
<div id="DetailsViewContainer">
<div ng-if="selectedTab === 'tab1'">
<div ng-include="getTabUrl('tab1')" ng-controller="DetailsController"></div>
</div>
</div>
<div id="CoursesViewContainer">
<div ng-if="selectedTab === 'tab2'">
<div ng-include="getTabUrl('tab2')" ng-controller="CoursesController"></div>
</div>
</div>
<div id="UsersViewContainer">
<div ng-if="selectedTab === 'tab3'">
<div ng-include="getTabUrl('tab3')" ng-controller="UsersController"></div>
</div>
</div>
The main html is already bonded with parent controller as follows:
'use strict';
angular.module('app.pages.manage').config([
'$routeProvider',
function($routeProvider, appSettingsProvider) {
$routeProvider
.when('/:lang?/group/landing/v2/manage/',
{
templateUrl: '/js/app/pages/manage/views/app.pages.managing.html',
controller: 'mainController'
});
}
]);
My requirement is that on click event, I want to initialize the bonded controller corresponding to selected tab. For three bonded controller in HTML file I don't have separate url config so I can't use $location service. I explored $state in UI router as I don't want to initialize the parent controller which might be helpful (after defining three different routes for three controllers). But I am using ng-route module so it's not an option for me.
So is there any ways I can make my controller reload programmatically while switching tab (without url)? I am also thinking to bind this controller through routing rather than ng-controller, but then also I want to prevent reloading the state of parent controller (mainController) and then reload only selected controller which I can't find a solution with ng-route.