Relative Content

Tag Archive for angulartypescriptrxjs

Promise not returning the real response

I have a page that contains tabs. When I click on a specific tab the component related to it is created. It goes in the ngOnInit and when I leave the tab onDestroy is called.

RxJs – Observable in service used within multiple pages. Need to trigger change detection manually

I’ve got observable in service, which is used by multiple pages. When observable value is changed on first page, then i go to the next page, subscription (on the second, current page) is not detecting any changes on this observable (which is logical), causing whole data flow to not being triggered. How to fix that, is there any proper way to manually trigger subscription to see changes?
Let’s say that on both pages i filter data by setting “Min Cars” and “Max Cars” by simple user input, and these are two observables. Then i go to the next page, which subscribes to these two observables, and do some API calls, nothing is happening, subscription is not seeing any observable changes, but these values indeed are “new” – but new for the first page, not for the second one.

Wait for API call to complete in Angular 14

In my Angular 14 application, I am making 2 API calls and then combine them using “combineLatest” from rxjs and then assigning the data to a variable.
I have to use that data/variable in a seperate function. How do I make sure that the second function ( seperate function ) is called only once the data/variable.

Angular Tour of Heroes HttpErrorResponse SyntaxError

Following step 6. of the tutorial, I’m using HttpClient to get data from the in-memory Web API. The build completes but I get my index.html file which results in a HttpErrorResponse with a SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON... Using Angular v17.

Unable to change a class Field in angular component using a Subject subscription

import { Component, OnInit } from ‘@angular/core’; import { AuthDataService } from ‘../Service/authDataService’; import { map } from ‘rxjs’; import { User } from ‘../Model/userModel’; import { CommonModule } from ‘@angular/common’; @Component({ selector: ‘app-success’, standalone: true, imports: [CommonModule], templateUrl: ‘./success.component.html’, styleUrl: ‘./success.component.css’, }) export class SuccessComponent implements OnInit { authenticated = false; constructor(private authService: AuthDataService) […]