I have just started with angular2 and the concept / architecture of how they implement templates using *ngFor
, *ngIf
and defining of my own <template>
elements is new to me.
What I would like to know though (because it wasn't broached in the documentation), is that are there any performance hits to defining huge quantities of templates?
For example;
<div *ngFor="let screen of screens" [ngSwitch]="screen.templateID"> <!-- huge loop -->
<template [ngSwitchCase]="0">{{screen.id}} | {{screen.templateURL}}</template>
<template [ngSwitchCase]="1">{{screen.id}} | {{screen.templateURL}}</template>
<template [ngSwitchCase]="1">{{screen.id}} | {{screen.templateURL}}</template>
</div>
Which could hypothetically generate thousands of templates, is it "acceptable" to generate so many templates or should I add more logic in to reduce the amount being instantiated?