I have a view as
<div class="wrapper" ui-view>
@RenderBody()
</div>
And the state that renderes a template called _BodyLayout
is
(function () {
angular.module('ngApp').config(configuration);
configuration.$inject = ['$stateProvider'];
function configuration($stateProvider) {
$stateProvider.state('dashboard', {
url: '/dashboard',
templateUrl: '/Shared/_Bodylayout',
});
}
})(angular);
I have a run method where the template should register all plugins exactly once for the template when rendered as :
(function () {
'use strict';
angular.module("ngApp").run(run);
run.$inject = ['$rootScope', 'plugin-factory', '$timeout'];
function run($rootScope, plugins, $timeout) {
$rootScope.$on('$viewContentLoaded', function (event) {
plugins.run();
});
}
})(angular);
But on console.log shows that this event runs for multiple times and the plugins.run()
method has been called at least 5 times for a single templateURL
!!! That makes my sidebar plugin behave weird .
Can anyone tell me why its running 5 times instead of one time for a single templateURL ?