Within most of my controllers, I am utilizing an initialization function called init() to set up controller-specific variables. Although this seems like a common practice, I have been unable to find any documentation supporting it. The options that I currently see available are:
- Keep things as they are
Switch to using the run or provider service
(function () { 'use strict'; CompanyController.$inject = ['CompanyFactory','LocationService']; function CompanyController(CompanyFactory,LocationService) { let vm = this; // Initialization function function init() { vm.company = { solutions: CompanyFactory.getSolutions(), }; // Set $location LocationService.setLocation('company-page'); } init(); } angular.module('app.company', []) .controller('CompanyController', CompanyController) })();