angular-services

How can I call multiple API's on a function with Angular?

六眼飞鱼酱① 提交于 2020-08-26 15:32:01
问题 I need to call 4 different API's on a single function which is need to execute one after another as my previous API result will use the next Call as a param. For example: I have a call API for geo Ip, then I need to call an another API which I need to pass lat and long which I have got from first API call. How can I achieve this task on angular 4? I heard about some methods like flatmap and forkjoin. Is this method can use? (I didn't have any code as I am little bit confused). 回答1: You can do

How can I call multiple API's on a function with Angular?

自作多情 提交于 2020-08-26 15:27:22
问题 I need to call 4 different API's on a single function which is need to execute one after another as my previous API result will use the next Call as a param. For example: I have a call API for geo Ip, then I need to call an another API which I need to pass lat and long which I have got from first API call. How can I achieve this task on angular 4? I heard about some methods like flatmap and forkjoin. Is this method can use? (I didn't have any code as I am little bit confused). 回答1: You can do

How to persist service data after reload in angular 5

爷,独闯天下 提交于 2020-07-18 14:28:49
问题 I have a service to pass data between components and when called it works but when i reload the service data gets reset.So when i searched on reload the memory is reset so is there a way to persist data even after reload without using any client side storage ? One thing i am curious is that can i achieve this using rxjs but i am not sure how this would help ?I fear to use localstorage because the data will be mostly objects or array and not user id or session id.Any inputs on this would be

How to persist service data after reload in angular 5

血红的双手。 提交于 2020-07-18 14:28:13
问题 I have a service to pass data between components and when called it works but when i reload the service data gets reset.So when i searched on reload the memory is reset so is there a way to persist data even after reload without using any client side storage ? One thing i am curious is that can i achieve this using rxjs but i am not sure how this would help ?I fear to use localstorage because the data will be mostly objects or array and not user id or session id.Any inputs on this would be

Could not load the config file in service - vendor js 65401

随声附和 提交于 2020-07-10 10:26:26
问题 It works fine in injecting into components. problem occurs in service injection. I am using runtime configuration for end points.it works in components.i can able to change in runtime but throws an error when injecting in other services global export class AppConfigService { static settings: IAppConfig; constructor(private http: HttpClient) {} load() { const jsonFile = `../assets/config/config.json`; return new Promise<void>((resolve, reject) => { this.http.get(jsonFile).toPromise().then(

Angular (v5) service is getting constructed before APP_INITIALIZER promise resolves

。_饼干妹妹 提交于 2020-05-25 09:35:44
问题 I'm expecting Angular to wait until my loadConfig() function resolves before constructing other services, but it is not. app.module.ts export function initializeConfig(config: AppConfig){ return () => config.loadConfig(); } @NgModule({ declarations: [...] providers: [ AppConfig, { provide: APP_INITIALIZER, useFactory: initializeConfig, deps: [AppConfig], multi: true } ] }) export class AppModule { } app.config.ts @Injectable() export class AppConfig { config: any; constructor( private