I tried
- $ stateChangeSuccess,
- $ routeChangeSuccess and
- $ viewContentLoaded
but I cannot run my custom jQuery initialization function after loading ng-include or if I switch it after the fact with ng-swith.
Index.html has an ng-view for dashboard.html that has this code.
<div class="row">
<div class="col-md-12">
Switch Dashboard View: <input type="radio" name="dashboardView" value="0" ng-model="vm.dashboardView" />Franchisee |
<input type="radio" name="dashboardView" value="1" ng-model="vm.dashboardView" />Real Estate
</div>
</div>
<div data-ng-switch="vm.dashboardView">
<div data-ng-switch-when="0">
<div data-ng-include="'/Views/Dashboard/FranchiseeDashboard.html'"></div>
</div>
<div data-ng-switch-when="1">
<div data-ng-include="'/Views/Dashboard/RealestateDashboard.html'"></div>
</div>
</div>
index.html has a controller that has this
$rootScope.$on("$viewContentLoaded", function () {
Interactions.init();
});
$rootScope.$on('$stateChangeSuccess',
function (event, next, current) {
Interactions.init();
}
);
$rootScope.$on('$routeChangeSuccess',
function (event, next, current) {
Interactions.init();
}
);
How can I run the jquery function after ng-switch has loaded ng-include?
source
share