An 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, an error in the browser console: "You can not bind to" ngIfElse ", as this is not a known property of the" div "."
My module looks like this (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 problem is? If I just remove the โ; else elseBlockโ from the div, the * ngIf operator works as intended. Therefore, I believe that my import is correct. Any help is appreciated.
rhino source share