How to use ngSwitch in angular2
Also facing the same issue Make sure
NgSwitch
should not be no template it should be on real element like Div*ngSwitchCase="expression"
should be nested insideNgSwitch
element
You need to import ngSwitch
from angular2/common
import {NgSwitch} from 'angular2/common'
https://angular.io/docs/ts/latest/api/common/index/NgSwitch-directive.html
ngSwitch
can't be on a <template>
element, only on real elements like <div>
Only ngSwitchCase
can be applied to <template>
elements
<template [ngSwitchCase]="match_expression_3">
Alternatively since final ng-container
can be used instead of <template>
with the more common syntax:
<ng-container *ngSwitchCase="match_expression_3">