One of a project where I'm handling is having below code.Can you tell me what it does? I know about *ngFor
and *ngIf
.But what are these [ngForOf]="topicdata"
and ngFor let-topic
? Can I simplify below code in a better way?
<ng-template ngFor let-topic [ngForOf]="topicdata">
<topic *ngIf="topic.num_of_definitions>0" [data]="topic"></topic>
</ng-template>
I would like to have it as shown below.
<topic *ngFor="let topic of topicdata" [data]="topic"
*ngIf="topic.num_of_definitions>0"></topic>
But then it shows this error:
[Angular] Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with *