How to use the data of subscribe() somewhere else?

return value from subscribe angular 6
how to get value outside typescript subscribe function
angular 6 observable example
return data from subscribe angular 6
return observable from subscribe
how to subscribe data in angular 6
angular observable pipe
observable of
onKeyUp(event: any): void {
  this.technologiesService.getTechnologies(event.target.value)
    .subscribe(data => {
       this.myData = data;
    });
}

The output of data is:

I would like to declare data as property, so that I could use it somewhere else. As you see, I have tried it with this.myData = data and myData is defined like this on the top of my class: myData = [];.

This is how I try to use myData:

<mat-option *ngFor="let data of this.myData | async" [value]="data.technology">
  <span>{{ data.technology}}</span>
</mat-option>

But I get the following errors:

ERROR Error: InvalidPipeArgument: '' for pipe 'AsyncPipe'

ERROR TypeError: Cannot read property 'dispose' of null

What am I doing wrong?


You should use one of subscribe or async pipe not together. it should be:

<mat-option *ngFor="let data of myData" [value]="data.technology">
  <span>{{ data.technology}}</span>
</mat-option>

when using subscride. and if you don't want to use subscribe but async, it should be:

<mat-option *ngFor="let data of myData | async" [value]="data.technology">
  <span>{{ data.technology}}</span>
</mat-option>

ts:

onKeyUp(event: any): void {
  this.myData = this.technologiesService.getTechnologies(event.target.value)
}

How to use the data of subscribe() somewhere else?, You should use one of subscribe or async pipe not together. it should be: <mat-​option *ngFor="let data of myData" [value]="data.technology">  But i want to use the data in that list together with some table somewhere else in another database. And i would need to have a report that needs the data from this 2 datasources. Whats the best way to get data out of the sharepoint site or db and make use of it somewhere for reporting etc..


this.myData is not async, so no need for the async pipe

<mat-option *ngFor="let data of myData" [value]="data.technology">
  <span>{{ data.technology}}</span>
</mat-option>

will fix it.

However, I would advice to instead make the observable an instance variable.

onKeyUp(event: any): void {
  this.myData = this.technologiesService.getTechnologies(event.target.value)
}
<mat-option *ngFor="let data of myData | async" [value]="data.technology">
  <span>{{ data.technology}}</span>
</mat-option>

Angular 6 observables, Now to use this in a component: this.myService.getMyData().subscribe( (data) => { /* Use the value from myData observable freely */ } );. If you use the CD or download TurboTax software, your tax files are stored wherever you save them on the computer that you use. In Windows the default location is the My Documents\TurboTax folder, but you could have saved them somewhere else. The tax returns data files for 2017 have the file name extension .tax2017.


<mat-option *ngFor="let data of myData | async" [value]="data.technology">
  <span>{{ data.technology}}</span>
</mat-option>

Understanding, creating and subscribing to observables in Angular, We subscribe to an observable in our template using the async pipe. This can be handy if you would first like to do something with the data before Creating observables is easy, just call the new Observable() and pass  I do not want to share all of my OneNote notebooks! I have several family computers using Microsoft 365 and we have upgraded family computers to Windows 10. Now everyone on the network has access to my notebooks. I want to remove them from OneDrive access and either save them locally or to DropBox where I have more privacy controls.


Angular 6 observables - extract data from .subscribe - html, How do I extract data out of the .subscribe() function and use it elsewhere? Assigning data to variables in the component so it could be used anywhere within  Therefore, you can use these resources somewhere else. Also, storing large amounts of data is much easier using big data technologies but more importantly, the data you store will be accurate


Using observables to pass values, They are used frequently in Angular and are the recommended technique for event This is the function that is executed when a consumer calls the subscribe​() As a general term, we refer to data published by an observable as a stream. an observable equivalent to the of(1, 2, 3) above, you could do something like this:. The first step to keeping your data usage in check is to understand what is using a lot of data and what isn’t. For example, checking your email—if even if you check it four hundred times a day—isn’t going to make a dent in a 1TB data package. But streaming videos over YouTube all day will, of course.


Observables in Angular, You can define custom events that send observable output data from a child to a A good example of usage can be found in the EventEmitter documentation. can use the filter() operator from RxJS to look for events of interest, and subscribe​  'The cloud is just someone else's computer', runs the joke. But if you're saying that, the joke is on you, because it means you don't understand what the cloud actually is.