when i have a provider like this
{ provide: SaModelService, useValue: 'foo@yahoo.com' }
i am able to get the value by just using like this in the component
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [
{ provide: SaModelService, useValue: 'foo@yahoo.com' }
]
})
export class AppComponent implements AfterViewInit {
constructor(private model: SaModelService) {
}
ngAfterViewInit() {
console.log(this.model);
}
}
where the service looks like this
import { Injectable } from '@angular/core';
@Injectable()
export class SaModelService {
}
now, how can i get the value while using the factory provider, ie
{
provide: APP_INITIALIZER,
useFactory: () => function () { return 'foo@yahoo.com' },
multi: true
}
now i have given this example just to simplify the scenerio but instead of just passing the string, i want to call some services inside the factory
my question is, is there any access to the variable, if not then how will i be getting the value which i would be using inside my component