I have a controller referenced by some html. And html changes to some event, so the controller function code is executed several times.
The problem is that I have a world of code that needs to be executed only once.
Here is the controller:
angular.module("someModule", [dependencies]) .controller("leftBoardController", function ($scope, someService) { (function createFilter(dataService) {
But it is executed every time the html changes.
Here's how the controller is inserted:
<section ng-controller="TreeMapController" ng-class="{ 'main-container-single': zoomed }" class="minContainer main-container">
Questions:
1) How to execute a controller function only once?
2) Or is there a way I can write this world of code that will only be executed once?
source share