0

post has a type observable not array , I need a help

enter image description here

1
  • 1
    Welcome to Stack Overflow. Please read the tour and How to Ask. Also, please do not post your code as an image, as this is causing a great number of drawbacks. Instead copy and paste the code into your question, and format it as such (using the corresponding 'code' button or Ctrl+K) . Same remark applies for error message. Commented Mar 21, 2018 at 11:06

2 Answers 2

2

Use the async pipe

<div *ngIf="(posts | async).length > 0"></div>

to get the values for the current emit of your Observable.

Sign up to request clarification or add additional context in comments.

1 Comment

Then i'd be happy if you accept the answer @theRealjen :)
0

Would like to improve previous ans.. async pipe itself check for null or undefined value therefore no need to check .length>0 . So improved answer would be

*ngIf="(post | async)"

or another way is

*ngIf="post.value.length>0"

Hope this will help you :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.