Linked Questions

Popular Questions

How to return object from Observable in Angular 7

Asked by At

I've got a application on Angular 7 and [email protected] I'm trying to get value from my Observable object and I don't know why it doesn't return.

There is my example code:

On my example html file I've got:

<hello name="{{ result.property1 }} {{ result.property2 }} {{ result.property3 }} {{ resultIsUndefined }}"></hello>

but the properties ({{ result.property1 }} {{ result.property2 }} {{ result.property3 }}) of my result are not displayed.

What is wrong with that?

The res object which I'm trying to return is still type of Observable. I was trying to cast it on MyResponseClasss but doesn't effect.

And this is my real problem. Why returned object is still type of Observable.

On this part of code:

if (result) {
  result.subscribe((result: MyResponseClass) => {
    this.resultIsUndefined = false;
    res = result;
  return res;

I want have a res with data type of MyResponseClass.

Related Questions