Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Sarah Dillon
Sarah Dillon
10,704 Points

Heart changing to blue not red. Any idea What could be wrong?

entry.component.css:

actions {
    padding: 1em 0;
}

.liked {
    color: red;
}

entry.component.html

<h2>{{title}}</h2>
<figure>
    <img src="{{photo}}">
    <figcaption>{{description}}</figcaption>
</figure>
<div class="actions">
    <button type="button" (click)="isLiked= !isLiked" [ngClass]="{liked: isLiked}">โค</button>
    <button type="button" (click)="showComments = !showComments">Comments ({{comments.length}})</button>
</div>

<div class="comments" *ngIf="showComments">
    <div class="comment" *ngFor="let comment of comments">
        <p><strong>{{comment.name}}</strong> {{comment.comment}}</p>
    </div>
</div>

code is exactly what Andrew has, Comment section works prefect!

Simon Coates
Simon Coates
28,694 Points

you might want to provide a URL as the post doesn't seem to be linked to a video.

1 Answer

Simon Coates
Simon Coates
28,694 Points

I haven't done this particular angular course (sorry!). If the embedding syntax is solid, then you probably need to post the complete code (maybe a url to a workspace snapshot) for debugging. I'd want to confirm that the data you expect is in fact present. I assume you've used angular debugging tools to confirm that you have access to the values that you expect. (if this is fine based on the your expectations of values provided, then the error has to have occurred earlier. I apologize if this is a little simplistic but I don't know what experience you have with debugging code. Process is verify assumptions and work by process of elimination.). And you can repost if that moves you to the top of the forum.