Angular 4.3.1
Angular CLI 1.2.3
Typescript 2.3.4
Within the Component Typescript file:
public saveName: string;
public overwrite: boolean;
After executing ng build --prod
, I encountered an error stating Type 'string' is not assignable to type 'boolean' while using the following markup:
<span>{{!overwrite || saveName}}</span>
OR
<button *ngIf="!overwrite && saveName">Save</button>
However, I found that the issue was resolved when I used the following syntax instead:
<span>{{saveName || !overwrite}}</span>
<span>{{overwrite || saveName}}</span>
<button *ngIf="saveName && !overwrite">Save</button>
<button *ngIf="overwrite && saveName">Save</button>
Can you explain why this error occurs?
Especially why it only appears when a negated boolean precedes a string?