279 questions
2
votes
1
answer
94
views
Why is it easy to check .closed on manual RxJS subscriptions, but not with takeUntilDestroyed() in Angular?
I am using RxJS for subscriptions in Angular. I noticed that when I manually subscribe to an observable and store the Subscription, I can easily check if it was unsubscribed using .closed, especially ...
1
vote
2
answers
87
views
Question about managing Observables in Angular 14
I'm new to Angular and right now I'm using Angular 14 and I have a problem that happens to me often.
For example, I have an array and I make a for loop to go through each of its indexes and I make a ...
1
vote
4
answers
227
views
Component making duplicate api 'GET' requests with behaviorsubject
I am working on an angular v14 application and I am having trouble figuring out how to fix an issue with my component making duplicate api calls.
I have a service that is shared between all components ...
2
votes
1
answer
67
views
Function which returns RxJs boolean observable - emit single value and complete
I have several functions in an angular project which return a boolean observable. Some of these functions could simply return an immediate result, but could also contain nested observables that open ...
1
vote
1
answer
2k
views
Difference between observable toSignal AND updating Signal value inside the subscribe of Observable
Are there any differences or advantages or proper way to do this?
Let's say I have an observable, I may receive it from backend call, a service or through a GUI event like scrolling event.
I have a ...
1
vote
1
answer
83
views
Form Control valueChanges observable in NgOnInit cannot be subscribed after navigating to same page
I have a page that navigates to itself with different parameter. This makes the NgOnInit don't be executed again. Sadly, in the NgOnInit I have an observable subscribed to deal with value changes in a ...
1
vote
1
answer
2k
views
Angular 17 - How to use async values in object using new @if syntax
In the previous *ngIf directives we were able to chain multiple async operations to not repeat the async pipe in the template but to reuse them later as one subscription, now I want to use the same ...
1
vote
1
answer
46
views
Unit Test case to mock Behavior Subject in Store
I have created a store to load address detail in behavior subject
@Injectable({
providedIn: 'root'
})
export class AddressStore {
private subjectAddress = new BehaviorSubject<Address[]>([...
1
vote
2
answers
113
views
Why does my observable doesn't catch error and stops working
I have a form. The user enters inputs and then a http request is sent to the backend to get data.
In the HTML template I have
data$ | async
In the component code I first have:
data$: Observable<...
2
votes
0
answers
1k
views
Display issue with an observable in Angular 17: the page loads indefinitely
I'm encountering an issue with Angular 17 where the use of an observable in my template seems to cause an indefinite loading of the page without displaying any errors in the browser console. This ...
0
votes
1
answer
650
views
Display loader only when api call will be longer then 1 sec
I have tried and I still trying to create a mechanism in Angular using rx that will display my loader, but only if the API call is longer than 1 second, if it is shorter I would not like to display it....
0
votes
2
answers
48
views
Can't pull json data from service into component to display
New to Angular and I'm trying to follow a tutorial. I'm pulling data into a shared service via an http call but from there I can't seem to get it into my component to be displayed in a table. I can ...
0
votes
2
answers
50
views
Which is the correct way to deal with an observed dependency?
I'm using Angular 15 and @angular/fire ^7.5.0 for my project.
I have a service that makes some calls to the Firestore database, but before i perform any action i need to recover some information from ...
0
votes
1
answer
276
views
Can't get through with async validators
So, I have a blog, and I'm trying to setup a check, on the creation of a new text, to lock the form if the title already exists.
I got a TextService
export class TextService {
private _url = "...
1
vote
1
answer
2k
views
How to get token from oidc-client-ts (Angular) [closed]
auth.service.ts
import { Injectable } from '@angular/core';
import { User, UserManager } from 'oidc-client-ts';
import { SettingsService } from './settings.service';
import { Observable, from } from '...
2
votes
2
answers
4k
views
Some trouble with "catchError" angular function
I had an error
this is an error
So I am learning how to catch errors with the catchError function in angular htttp services
I have a ts file that executes function handler errors
import { Injectable } ...
0
votes
1
answer
152
views
ionic 4 - How to wait for two observables to be subscribed before getting data
I'm accessing this route fine:
http://localhost:8100/questions/question?id=3
Now I'm in trouble on how to handle two subscribers at the same time.
The first subscriber loads the questions array from ...
0
votes
2
answers
347
views
How can I get every property from the JSON I'm receiving? error TS2339: Property '' does not exist on type ''
I'm trying to get the information received via JSON, but I can't access it. The data arrives, as shown in the image below:
screenshot from Console
When I tried to access any property from it, I ...
0
votes
1
answer
533
views
Angular: RouterGuards, HTTP requests and race conditions
I'm trying to create a RouterGuard in Angular that gets a response from the backend about the User's login status. The problem is that the HTTP request returns a Subscription with async concrete ...
0
votes
2
answers
549
views
i Need to take one element in result observale
I want to retun only a valure:
in html
<tr *ngFor="let valCorr of valueCall| async">
<th>{{valCorr }}</th>
</tr>
in ts
valueCall:Observable<number[]&...
0
votes
1
answer
1k
views
concatMap vs. switchMap when observable only returns one value in Angular
I get the difference between concatMap and switchMap when an observable returns more than one value. However when all observables just return a single value, is there any advantage to using one over ...
0
votes
1
answer
1k
views
Tracking multiple control forms for individual processing in Angular Reactive Forms (Clean Code)
I'm using Angular 11.0.2. I have a form group with 20 fields that are displayed in two tables. Some of this formControls are shared between two forms.
~9 of those formControls are text input fields ...
0
votes
1
answer
760
views
Type error when using EventEmitter as observable
I've created a simple column filter component so I can filter on a value in a table. All is working as expected but I have some issues when using proper typing for the event emitter.
The relevant code ...
1
vote
2
answers
747
views
Angular wait service subscription from component?
I have a problem filling a Users autocomplete on first load.
This is my UsersService:
public users: User[] = [];
constructor(private http: HttpClient) {
this.http.get<User[]>(environment....
0
votes
1
answer
1k
views
how can i show the data received from backend api in angular
Im currently trying to show the data of an employee after he loggin to his account, i can get the data of the employee from the backend by his username and i can console logged it , but when i assign ...
0
votes
1
answer
171
views
Angular 12 Dynamic User Data
I am trying to convert myself from knockoutjs, but i am struggling with how dynamic data/observables work in angular 12.
I want to be able to prepopulate an array with some data from a service, but ...
0
votes
0
answers
1k
views
Angular, how to change/update specific value of an object in Observable?
I'm 'studying' Angular from a course-book. The example in book is not done by observable, but I have made my example with Json-server and a json file.
I would like to update the rating value of the ...
-2
votes
2
answers
804
views
Using RxJS in Angular with conditional / combined subscriptions
in my Angular App I have an API service like so that contains two methods:
addComment(id: string, comment: string): Observable<any> {
return this.http.post(`api/${encodeURIComponent(id)}/...
1
vote
1
answer
101
views
property not found mapping combining streams with RxJS in angular
Hi I have this two streams with Ofertas and concursos
ofertas$ = this.dataService.getOfertas();
concursos$ = this.dataService.getConcursos();
ofertasConOrganismos$ = forkJoin([
this.ofertas$,
this....
1
vote
1
answer
4k
views
How to map an Observable with values from another observable
I obtain my Ofertas here
getOfertasByYear(year:number): Observable<Oferta[]> {
return this.http.get<Oferta[]>(`${this.urlWebAPI}/ofertas/year/${year}`)
.pipe(
map(ofertas=>
...
1
vote
2
answers
788
views
How to randomize (shuffle) an angular Observable?
I am working with angular and firebase. I have 170 products in firebase. when I call the firebase I get the Observable of the products which stored in products$.
Problem: I would like to shuffle all ...
1
vote
3
answers
9k
views
Angular : ERROR RangeError: Maximum call stack size exceeded message when I type in inputs
I'm getting ERROR RangeError: Maximum call stack size exceeded message in console when I type something in one of this inputs
app.component.html
<div class="container-wrap">
<...
0
votes
4
answers
954
views
Angular 12 - Using class as http observable
Using Angular 12
The HTTP service returns the following response from the backend
Array<{
id: string;
title: string;
created: string;
}>
// Service
public list(): Observable<Array&...
0
votes
0
answers
137
views
Angular rendering before loaded data?
In Angular 9, I'm getting data from subscribe() inner forEach. I can see that my variable is loaded with data, but Angular is not rendering. I suspect that Angular is rendering before my variable is ...
0
votes
1
answer
617
views
Observer is not working after next(undefined)
I have an currentUser$ in AccountService;
private currentUserSource = new ReplaySubject<User>(1);
currentUser$ = this.currentUserSource.asObservable();
In login method:
this.currentUserSource....
1
vote
1
answer
69
views
Angular data sharing architecture
I feel like I fundamentally misunderstand one part of Angular, imagine the following:
You have a navbar component which shows the logged in user, something like:
<nav *ngIf="user$ | async as ...
0
votes
2
answers
2k
views
How to wait for code inside subscribe to finish before going to next iteration in forEach loop in Angular
In the below code, I have a for loop inside that one API is getting called. I want the 1st API call to be finished and code inside subscribe fully executes first and then the next iteration of for ...
0
votes
1
answer
783
views
How to automatically display the new record to a list when a new record is added in Angular?
I'm currently doing an Angular app with CRUD operations and Springboot API as a back end. The problem is when I add a new user, it successfully added but it does not automatically display on the List. ...
1
vote
2
answers
1k
views
How to return REST data to observable and then apply logic on APP_INITIALIZER? [Angular 12]
In my angular 12 app Im trying to return some api data before any of my other components load (including the app component). I want to place some returned items in local storage that will be able to ...
0
votes
1
answer
567
views
Angular display table data from object array but updating last column from another API call returns undefined value
I am trying to display a table by looping an array of objects fetched from backend API.
<tr *ngFor="let obj of objarray">
<td>{{obj.property1}}</td>
&...
2
votes
1
answer
3k
views
Angular Navbar change when Logged in
I have a navbar in my App component:
app.component.html
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-...
0
votes
1
answer
1k
views
Next lines of code executes before getting API response in Angular 11
In my form there are some Checkboxes. Checkboxes are dynamically generated based on the values getting from API response. If the API response is not null and there is some value then I want to make ...
1
vote
1
answer
643
views
Tail recursive observable returning function with Rxjs
Suppose I have a service with a method that pings an url until a certain condition is met. After that it returns the result. The whole thing should be built with Observables (to be easily cancellable ...
1
vote
2
answers
2k
views
Type 'Observable<true | undefined>' is not assignable to type 'Observable<boolean>'
I am trying to create an authorized system for users.I am using Angular11.I am absolutely new in angular.I return also a boolean type in my code. but still, I found an error.
here is my code below:-
...
0
votes
1
answer
231
views
nothing happens when the observable is completed in my angular component
In my Angular component, I have this
ngOnInit(): void {
this.route.paramMap
.pipe(
tap(item=>console.log(item))
)
.subscribe(
params => {
const proyectoId = params.get('proyectoId');
...
0
votes
3
answers
1k
views
Sending data to components through services using the subject in Angular
I have a component that displays a message for a few seconds, my problem is that I can not subscribe to the service and perform the necessary operations, how to do this?
This was a short example, I ...
0
votes
1
answer
994
views
RXJS - subscription trigger multiple times. Nested Subscription with multiple if else conditions
want to optimize the following code:
multiple subscription in multiple if else statements.
consider:-
getList(): void {
this.subs.sink = this.subscription1.subscribe((user) => {
if (user) ...
0
votes
1
answer
141
views
problems handling asynchronism and observables in Angular
In my project I need to calculate some data in function of some dates (month and year) so once I have the dates in the array "this.etiquetasEjeX". I loop them to calculate the data in my ...
2
votes
2
answers
3k
views
Check if Observable is empty is not possible, so what other option I have?
I write an angular 11 and I'm pretty new to Observables and Subjects.
I have a mat-autocomplete component and it's results are divided to categories. the last category is an articles category and i ...
0
votes
1
answer
674
views
Angular jest, test if inside observable
Function to be tested
changeIva(idTax: number, index: number): void {
this.documentService.getTaxById(idTax).subscribe(tax => {
if (tax.codigo === 'ISE') this.openModal(index);
});
}...