Answer the question
In order to leave comments, you need to log in
Why didn't the provider work?
Token:
export const SETTINGS = new InjectionToken<Settings>('SETTINGS');
providers: [
ExecutionFiltersRepository,
ExecutionSortingsRepository,
{
provide: SETTINGS,
useFactory: executionSettingsFactory,
deps: [ExecutionFiltersRepository, ExecutionSortingsRepository, HttpClient],
},
]
const executionSettingsFactory = (
filtersRepository: ExecutionFiltersRepository,
sortingRepository: ExecutionSortingsRepository,
http: HttpClient,
) => {
return () => {
alert(1);
return new ExecutionSettings(filtersRepository, sortingRepository, http);
};
};
@Injectable()
export class ExecutionSettings {
constructor(
private filtersRepository: ExecutionFiltersRepository,
private sortingRepository: ExecutionSortingsRepository,
private http: HttpClient,
) { alert(2);}
}
Answer the question
In order to leave comments, you need to log in
Your factory `executionSettingsFactory` returns a closure, most likely it was meant:
const executionSettingsFactory = (
filtersRepository: ExecutionFiltersRepository,
sortingRepository: ExecutionSortingsRepository,
http: HttpClient,
) => {
alert(1);
return new ExecutionSettings(filtersRepository, sortingRepository, http);
};
there in the console is not written a thread like "arrow functions are not supported"?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question