0

I have a Observable of service data which return true or false value ,when call the servive which returns

 let m =this.myService.checkCapabilityOf(constantvalue);
console.log(m);

enter image description here

below formatenter image description here enter image description here

Here in the observable value it return false, I need to get the value so i have subscribe the observable.

let m =this.myService.checkCapabilityOf(constantvalue).subscribe(value => value);
console.log(m);

But it returns below format , howto get a value from observableenter image description here

Mohamed Sahir
  • 2,482
  • 8
  • 40
  • 71

1 Answers1

0

Use the following code to get the value from Observable subscribe.

let m;
this.myService.checkCapabilityOf(constantvalue).subscribe(value =>{ 
 m = value
 console.log(value);

});

Remember that it is an async call then you can not get the value from out site of the subscribe. you can save the reference or get a copy of the object but just until the subscribe responses you will get the value.

Abel Valdez
  • 2,368
  • 1
  • 16
  • 33