I have a directive: in the template:
<territorial-selector></territorial-selector>
in js:
app.directive('territorialSelector', function() { return { restrict: 'E' ,templateUrl: 'partials/territorial-selector.html' ,controller: 'TerritorialSelectorController' }; };
As you can see, using the "TerritorialSelectorController" directive
Elsewhere, I have a button that should execute the loadTerritories () method from the TerritorialSelectorController. I created this button:
<button ng-controller="TerritorialSelectorController" ng-click="loadTerritories()">BUTTON</button>
The problem is that in this case the TerritorialSelectorController creates two times. Here is the TerritorialSelectorController code:
app.controller('TerritorialSelectorController', ['$scope', function($scope) { alert('AAAAA');
And I need only one controller object.
Ildar source share