Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a component with a form where the user can upload a package and leave comments, but I can't make it display some value if there is no comment from the user.

<div class="sub-title">Submitter comments</div>
<span *ngIf="getLastSubmitterComment(packageToReview) as comment">{{ comment }}</span>
<div class="sub-title">Reviewer comments</div>

I want to display e.g "No comments" when this form is sent for approval.

question from:https://stackoverflow.com/questions/66064008/display-no-comments-if-there-is-no-value-in-a-section

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
278 views
Welcome To Ask or Share your Answers For Others

1 Answer

you can use Angular structural directives in order to show/hide an element in your application

NgIf, NgFor, and NgSwitch

you can also use the ternary operator as well:

<span> {{ comment.length ? comment : 'comment is not available' }} </span>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...