I have an Angular controller loaded in a view:
<div ng-controller="MyCtrl">
<p ng-bind-html="content"></p>
</div>
This partial is loaded into different views, and as a result the controller gets instantiated multiple times. In the controller, I'm detecting for location change:
angular.module('MyApp')
.controller('HintCtrl', function ($scope, $rootScope) {
$rootScope.$on('$locationChangeSuccess', function () {
alert("HI");
});
});
Each time I change my location, this fires once for each time the controller was ever loaded. How can I have this run only once?