For some reason, my controller is double called, when I switch between resource 1 and resource2.
Here\'s the code:
index.html
I'm still learning angular and I have experienced this problem, when I wrote the directive and included controllers.
I hope will help someone as I spent quite some time to see what I did:
.directive("list", function() {
return {
restrict: "E",
transclude: true,
replace: false,
templateUrl: "contacts/list",
controller: "CMSController", //- not needed at all
controllerAs: 'cCtrl'//- not needed at all
};
})
function config($routeProvider, $locationProvider, $httpProvider) {
$routeProvider
....
.when('/CMS', {
templateUrl: 'contacts/index',
controller: 'CMSController',
controllerAs: 'cCtrl',
access: {restricted: true}
})
....