stack overflow
stack overflow

Reputation: 3

How to get value from Observable

Please have you any idea how to get _value from:

this

I have this function:

jobsLength(){
   const jobslength:any;
   jobslength=this.searchLogic.items$
   console.log(jobslength)
};

Upvotes: 0

Views: 7913

Answers (1)

Yong Shun
Yong Shun

Reputation: 51125

You need to subscribe to the items$ Observable to get the data.

jobsLength() {
   this.searchLogic.items$.subscribe((value: any[]) => {
       let jobs: any[] = value;
       console.log(jobs);
       console.log(jobs.length);
   });
}

Sample Solution on StackBlitz


References

Observable (Subscribing)

Upvotes: 3

Related Questions