angular - ng2 - Difference between ng-container and ng-template tags -


can please illustrate difference between using <ng-container> , <ng-template> elements?

i not find documentation ngcontainer , don't quite understand difference between template tag.

a code example of each help.

both of them @ moment (2.x, 4.x) used group elements without having introduce element rendered on page (such div or span).

template, however, requires nasty syntax. example,

<li *ngfor="let item of items; let = index; trackby: trackbyfn">...</li> 

would become

<template ngfor let-item [ngforof]="items" let-i="index" [ngfortrackby]="trackbyfn">   <li>...</li> </template> 

you can use ng-container instead since follow nice * syntax expect , familiar with.

<ng-container *ngfor="let item of items; let = index; trackby: trackbyfn">   <li>...</li> </ng-container> 

you can find more details reading this discussion on github.


note in 4.x <template> deprecated , changed <ng-template>.


use


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -