observable

What is the proper way for binding data to cascade dropdown / autocomplete lists in Angular?

℡╲_俬逩灬. 提交于 2021-01-28 11:14:38
问题 I use mat-autocomplete in several places in my project and fille them as shwon below on form loading: countries: CountryDto[] = []; cities: CityDto[] = []; getCountries() { this.demoService.getCountries().subscribe((list: CountryDto) => { this.countries = list; }); } getCities(countryId) { this.demoService.getCities(countryId).subscribe((list: CityDto) => { this.cities= list; }); } However, when I tried to use a second list as cascade, I cannot make the second one to fill according to the

Transform data in an Observable

倖福魔咒の 提交于 2021-01-28 09:43:25
问题 I'm retrieving a list of items from an Observable on my Angular service. Inside every item, I have an array with a list of subjects. For every subject, I need to make another call to get its details (e.g. name, description, etc.). Data structure: - post1 - subjects: ['books', 'cars', 'movies'] With that list, I have the id from every subject but I need to return an observable containing all subjects belonging to that post (and their details). AppService.ts getPost(id: string): Observable<Post

Transform data in an Observable

天大地大妈咪最大 提交于 2021-01-28 09:42:04
问题 I'm retrieving a list of items from an Observable on my Angular service. Inside every item, I have an array with a list of subjects. For every subject, I need to make another call to get its details (e.g. name, description, etc.). Data structure: - post1 - subjects: ['books', 'cars', 'movies'] With that list, I have the id from every subject but I need to return an observable containing all subjects belonging to that post (and their details). AppService.ts getPost(id: string): Observable<Post

Angular service observable to return nested array data

混江龙づ霸主 提交于 2021-01-28 07:48:04
问题 My endpoint contains like this { 'dsco_st_license': { 'ttco_st_license': [ { 'csl_state': 'AK', 'csl_license_name': 'Specialty Contractor', 'csl_license_code': 'Communications', 'csl_license_number': '123456' }, { 'csl_state': 'AL', 'csl_license_name': '', 'csl_license_code': '', 'csl_license_number': 'Not Required' } ] } } and here is my service ngOnInit() { this._WebLicenseServiceService.getWebLicensesHttpCall() .subscribe(data => this.weblicenses = data, err => console.error('Observer got

Wrapping Promise based JavaScript HTTP client with RxJs Observable

谁都会走 提交于 2021-01-28 01:48:01
问题 I was thinking of using Observables to add .flatMapLatest() & .throttle() functionality to a Promise based HTTP client library (axios). But I'm not going to change the whole application to work with Observables, so I would need something like this: Promise -> Observable -> Promise Anyone managed to do something like this? None of the examples I've found do exactly that. I know that RxJs provides a way to make an Observable from Promise and then convert it back to Promise, but haven't figured

Wait for observable in for loop to finish before continuing loop in Angular 5

為{幸葍}努か 提交于 2021-01-27 19:21:58
问题 I'm looping through an array of objects (called projects). The forEach loop contains a service call that returns an observable. I'm trying to wait to process the next project in the array until the observable within the loop completes. What should I use? I tried forkJoin already. projects .forEach(project => { this.imageService.getProjectImages(project.projectId.toString(), true, true, undefined) .catch(err => observer.error(err)) .finally(() => { // process next project }) .subscribe((image:

Using RxJS to build data from multiple API calls

百般思念 提交于 2021-01-27 11:28:03
问题 I'm trying to get a better understanding of how to use RxJS Operators to solve a specific problem I'm having. I actually have two problems but they're similar enough. I'm grabbing a bunch of documents from an API endpoint /api/v3/folders/${folderId}/documents and I've setup services with functions to do that, and handle all of the authentication etc. However, this array of document objects does not have the description attribute. In order to get the description I need to call /api/v3

Using RxJS to build data from multiple API calls

℡╲_俬逩灬. 提交于 2021-01-27 11:27:50
问题 I'm trying to get a better understanding of how to use RxJS Operators to solve a specific problem I'm having. I actually have two problems but they're similar enough. I'm grabbing a bunch of documents from an API endpoint /api/v3/folders/${folderId}/documents and I've setup services with functions to do that, and handle all of the authentication etc. However, this array of document objects does not have the description attribute. In order to get the description I need to call /api/v3

Is observable and promise compatible in rxjs?

穿精又带淫゛_ 提交于 2021-01-27 07:08:03
问题 In the official angular2 tutorial it contains the following code getHeroes(): Promise<Hero[]> { return Promise.resolve(HEROES); } ngOnInit(): void { this.route.params .switchMap((params: Params) => this.heroService.getHero(+params['id'])) .subscribe(hero => this.hero = hero); console.log(this.route.params); console.log(this.route.params .switchMap((params: Params) => this.heroService.getHero(+params['id']))); } Now we know that this.route.params returns an observable, while this.heroService

How to convert the value stored in Observable<any> to a string, in typescript?

半城伤御伤魂 提交于 2021-01-27 05:51:44
问题 Hi I am new to Angular and TypeScript. I need the value of an Observable in the format of a string, how does one do this? the BmxComponent file export class BmxComponent { asyncString = this.httpService.getDataBmx(); currentStock = this.httpService.getDataBmx2(); //this is what I want to covert to a string so I can pass it to onSubmit() onSubmit() { const asnNumm = this.currentStock; // passing it here changes my database, see below this.httpService.sendData({ stock: asnNumm }) .subscribe(