The next service provider is successfully registered. Other controllers can use the service without problems. My question is, how do I access the provider to configure it before the service is created by the $injector service?
module apiService{ export interface IBaseService{ leagueID: number; } export interface IApiBaseServiceProvider extends ng.IServiceProvider{ setLeagueID(leagueID: number): void; $get(): IBaseService; } class BaseServiceProvider implements IApiBaseServiceProvider{ private _leagueID: number; $get(){ return new BaseService(this._leagueID); } setLeagueID(leagueID: number){ this._leagueID = leagueID; }; } class BaseService implements IBaseService{ constructor(private _leagueID: number){}; get leagueID(){ return this._leagueID; } } angular.module('apiService').provider('apiService.baseService', BaseServiceProvider); }
I tried to use the class name as an accessor, but the whole application does not work.
angular.module('apiService').config(['BaseServiceProvider', function(baseServiceProvider: IApiBaseServiceProvider){ baseServiceProvider.setLeagueID(12); }]);
The documentation shows only an example when a named function is used to create an instance of a provider. Later in the explanation, the name of the function name is used to access the provider.
Since the TypeScript class is used in the above example, there is no named function to access the provider. So, how to configure the provider when using the TypeScript class?
proff321
source share