Questions tagged [angular-observable]
270 questions
9
votes
2 answers
Angular5 HttpInterceptor depending on the result of an Observable
I am trying to implement using Angular5 an HttpInterceptor to inject an Authorization header in all HTTP requests.
I rely on a third party library (ADAL, here called AuthService) that exposes a acquireToken() method to get the token to be used for…

leonixyz
- 1,130
- 15
- 28
8
votes
3 answers
RXJS Stop propagation of Observable chain if certain condition is met
Introduction
I'm trying to create a route guard in Angular2+ using Observable from the shared service which holds the string value of current user role.
The problem is obviously in shifting my mind from Promises to Observables.
What I made so far…

maljukan
- 2,148
- 2
- 25
- 35
8
votes
2 answers
Patchvalue with null object
I am using Angular 6 and I am trying to perform patchValue to populate my form with data from an observable http call. Everything works great except I have a secondaryPhone value that can be null the json that populates the observable object. When…

user1041169
- 639
- 2
- 9
- 18
8
votes
1 answer
Complete not getting called in Observable subscribe method
I am working on the angular application and I am trying to use RxObservable. Below is the sample code.
getMyData(){
console.log('get my account data called');
this.AccountService
.getMyAccountData()
.filter(_res => _res !== null)
…

romie99
- 305
- 3
- 4
- 18
6
votes
3 answers
Multiple subscriptions nested into one subscription
I find myself puzzled trying to set a very simple rxjs flow of subscriptions. Having multiple non-related subscriptions nested into another.
I'm in an angular application and I need a subject to be filled with next before doing other…

Zacharie Ménétrier
- 306
- 2
- 7
6
votes
4 answers
Angular 5 - Promise vs Observable - performance context
I have an Angular 5 site that receives data from a REST API, something like 1-4 requests to the API each page,
and what happens is that the requests sometimes take a long time(and sometimes not).
Now, all the requests are being performed in one…

levi
- 1,077
- 2
- 11
- 24
6
votes
1 answer
Angular 4 Subscribing to observable is not updating after change
I have a service with an observable which is being subscribed to via a component. This seems to work as the subscriber is showing the initial value. I have another component which is then updating the observable however the new value does not get…

Steve
- 4,314
- 3
- 16
- 21
5
votes
2 answers
Observable stops firing even when catching the error
I'm facing with a very strange behavior on my project, I have a simple Angular service with the below code:
seatClick$ = new Subject();
and a method on the service that fires the observable:
handleSeatClick(seat: Seat) {
…

TomerMiz
- 377
- 1
- 3
- 13
5
votes
1 answer
Render a Observable object property in Angular template
I have the following Angular 7 component:
export class PostComponent implements OnInit {
post$: Observable;
constructor(private postService: PostService) { }
ngOnInit() {
this.post$ = postService.getPostById(25);
}
}
On…

Miguel Moura
- 36,732
- 85
- 259
- 481
5
votes
4 answers
How i can display a MatSnackBar from a Service with Angular Material?
Im using: Angular V6.1.0, Angular Material V6.4.1
Im trying catch the HTTP errors and show them using a MatSnackBar. I seek to show this in every component of my application (where there is an http request). So as not to do the repetitive…

Simón Farias
- 732
- 2
- 8
- 21
5
votes
1 answer
How to update subscribers of Angular Observable
In my angular app, I have created an Observable to provide data updates to multiple components. When user clicks on a button, all the Subscribers of the Observable should be updated with different set of data. Below is the code.
import { Observable…

dGayand
- 599
- 1
- 7
- 15
4
votes
2 answers
Can this PrimeNG data table take directly an Observable (emitting array of objects) instead the standard array of objects?
I am working on an Angular application using PrimeNG. In particular I am using a PrimeNG DataTable, this coponent: https://primefaces.org/primeng/showcase/#/table
I have no problem using it in the way shown in the previous officual documentation.…

AndreaNobili
- 40,955
- 107
- 324
- 596
4
votes
2 answers
Type 'void' is not assignable to type 'ObservableInput'
I am getting the following error
Argument of type '(user: User) => void' is not assignable to parameter
of type '(value: User, index: number) => ObservableInput'. Type
'void' is not assignable to type 'ObservableInput'.
getCurrentUserDb()
…

user13321892
- 49
- 1
- 5
4
votes
2 answers
angular assign different observable to template with async based on condition (any memory leak ?)
I need to render data from different ngrx stores based on some flag. Both stores gives same type of data.
Approach 1
{{…

Dyapa Srikanth
- 1,231
- 2
- 22
- 60
4
votes
1 answer
How to use observable subscription in forloop angular 7
I have an array users:
[0: {id:123, firstname:'xyz', lastname:'abc'}, 1:{id:456, firstname:'foo', lastname:'bar'}, 3:{id:567, firstname:'bar', lastname:'baz'}]
I have to loop through this array and call service API to get user appointments.
Method…

Always_a_learner
- 4,585
- 13
- 63
- 112