I find my way with my first Angular application, and one of the services (used to generate SQL query strings) must be initialized with the schema declared in the block constant. At the moment, the scheme / configuration is not completed, so I do a little processing, and the result then becomes available for the private variable inside the service.
I would like to consult a little with best practice at the same time. There seem to be 3 options.
1) Open a public function initin the factory and call it from another place
This is an opportunity, but I do not want to start the factory from another place (this will be the first thing that loads).
2) Use IIFE in the factory body
It may be smelly, but itβs actually normal.
angular.module('dataService', [])
.constant('DB_CONFIG', {
})
.factory('sqlQueries',
['DB_CONFIG',
function(){
var privateStuff_;
(function(){
privateStuff_ = result;
})();
return {
publicMethod1: publicMethod1
}
}
])
3) Use the block run
Angular run, . , , , factory ? . , .
- ?