Can't bind to 'article' since it isn&#

2019-09-19 09:22发布

问题:

Getting an error in console: Can't bind to 'article' since it isn't a known property of 'reddit'

Reddit.component.ts

app.component.html

also even tried putting same code in reddit.component.html

But the results are same. Sorry I am very new to angular2. Learning stage

Help me on this!!!

回答1:

Remove the ngFor from the app.component.html

it will be,

<reddit [article]="article"></article>

so you are passing the article to the child component reddit , so you need to define the input on the reddit component.

@Input() article: Article[];