I am facing a difficult issue with the timing of Angular JS life cycle in relation to the code snippet below. There seems to be a random occurrence where controllers dependent on this code are loaded before it, leading to errors. Even after multiple attempts, I cannot consistently reproduce the problem. Is there a way to ensure that this specific code loads before any other controllers?
(function() {
'use strict';
angular
.module('securityMaintenance')
.directive('buttons', buttons);
function buttons() {
var directive = {
restrict: 'AE',
scope: {},
templateUrl: 'app/shared/buttons/buttons.html',
controller: ButtonsController,
controllerAs: 'vm'
};
return directive;
}
ButtonsController.$inject = ['$location', '$route', '$scope', '$rootScope'];
// ReSharper disable once InconsistentNaming
function ButtonsController($location, $route, $scope, $rootScope) {
...
init();
function init() {}
}
}
})();