The example directly from angular.io will not work for me:
<button (click)="show = !show">{{show ? 'hide' : 'show'}}</button>
show = {{show}}
<br>
<div *ngIf="show; else elseBlock">Text to show</div>
<template #elseBlock>Alternate text while primary text is hidden</template>
Instead, the browser console errors: "Can't bind to 'ngIfElse' since it isn't a known property of 'div'."
My module looks like this (I am including CommonModule):
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
FormsModule,
CommonModule
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
So I'm not sure what the issue is? If I simply remove the "; else elseBlock" from the div, the *ngIf statement works as intended. Therefore, I believe my imports are correct. Any help is greatly appreciated.