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 trialHarley Jean
2,070 PointsAdding the input decarator produces a error in console and the photos do not display. What am I missing ?
The last part of this video where we add a decarator does not output the same results. The console is reading "Cannot read property 'title' of undefined"
Here is my code
import { Component,Input } from '@angular/core';
import {Entry} from '../shared/entry.model'
@Component({
selector: 'app-entry',
templateUrl: 'entry.component.html',
styleUrls: ['entry.component.css']
})
export class EntryComponent {
@Input() entry: Entry;
}
The corresponding html file seems okay too. I've been staring at this for hours any help would be appreciated
<h2>{{entry.title}}</h2>
<figure>
<img src="{{entry.photo}}">
<figcaption>{{entry.description}}</figcaption>
</figure>
<div class = "actions">
<button type="button" (click)="isLiked = !isLiked" [ngClass]="{liked: isLiked}">ā¤</button>
<button type="button" (click)="showComments = !showComments"> Comments ({{entry.comments.length}})</button>
</div>
<div class = "comments" *ngIf="showComments">
<div class="comment" *ngFor = "let comment of entry.comments">
<p><strong>{{comment.name}}</strong>{{comment.comment}}</p>
</div>
</div>
2 Answers
Jeffrey K
14,467 PointsI was having a similar issue. Try deleting your node modules folder and running npm install
in your console.
Vlad Popa
1,995 PointsSame issue. I don't know how to fix it.