ERROR Error: ngIfElse must be a TemplateRef, but received 'true'
HTML File
<select class="form-control">
<option selected value="0">Select Manufacturer</option>
<option *ngFor="let brand of allMakes">
{{ brand.brand }}
</option>
</select>
ts file
this.allMakes = [{
id: '1',
brand: 'Mazda'
},
{
id: '2',
brand: 'Audi',
}];
It all started right after i upgraded from Angular 5 to Angular 6
Console Log Error
ERROR Error: ngIfElse must be a TemplateRef, but received 'true'.
at Vt (main.6e360f04b7d39ee1dc33.bundle.js:1)
at t.set [as ngIfElse] (main.6e360f04b7d39ee1dc33.bundle.js:1)
at Sa (main.6e360f04b7d39ee1dc33.bundle.js:1)
at main.6e360f04b7d39ee1dc33.bundle.js:1
at main.6e360f04b7d39ee1dc33.bundle.js:1
at es (main.6e360f04b7d39ee1dc33.bundle.js:1)
at Os (main.6e360f04b7d39ee1dc33.bundle.js:1)
at Object.updateDirectives
(main.6e360f04b7d39ee1dc33.bundle.js:1)
at Object.updateDirectives (main.6e360f04b7d39ee1dc33.bundle.js:1)
at ts (main.6e360f04b7d39ee1dc33.bundle.js:1)
For ngIf
with else block you need to use <ng-template>
block as a else in your .html
file.
Here is the sample code:
<div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
<ng-template #elseBlock>Content to render when condition is false.</ng-template>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With