Issue
I'm learning Angular 2 recently. And I can't understand the meaning of "*" in *ngFor. Could anyone explain it for me?
Thank you!
Solution
When we reviewed the NgFor and NgIf built-in directives, we called out an oddity of the syntax: the asterisk (*) that appears before the directive name.
The * is a bit of syntactic sugar that makes it easier to read and write directives that modify HTML layout with the help of templates. NgFor, NgIf, and NgSwitch all add and remove element subtrees that are wrapped in tags.
Meaning
ngFor
can only be applied to a <template>
element.
*ngFor
can be applied to any element. When used the <template>
element is created behind the scene.
Answered By - daan.desmedt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.