While working on my Angular 4 project, everything seemed to be running smoothly in the developer server without using the --prod
flag. However, when I tried running ng build --prod
, I encountered the following errors:
Note: The project was built using ng cli version 1.4.2
The variable causing the error is:
userHotelLength = '0';
Error Output:
Date: 2018-01-24T17:25:24.719Z
Hash: a7059ea62cc4eeb37fde
Time: 12033ms
chunk {0} styles.c9da94e47a8635066285.bundle.css (styles) 142 kB {3} [initial] [rendered]
chunk {1} polyfills.3bc34265385d52184eab.bundle.js (polyfills) 86 bytes {3} [initial] [rendered]
chunk {2} main.e402deade8b026b7d50e.bundle.js (main) 84 bytes [initial] [rendered]
chunk {3} inline.9d07561b59257af76b95.bundle.js (inline) 1.45 kB [entry] [rendered]
ERROR in ng:///home/x/y/z.html (10,6): Operator '==' cannot be applied to types 'string' and 'number'.
ERROR in ng:///home/x/y/z.html (29,6): Operator '!=' cannot be applied to types 'string' and 'number'.
ERROR in ng:///home/x/y/z.html (36,6): Operator '==' cannot be applied to types 'string' and 'number'.
Code Snippet:
<div class="my-booking-card loading-card" *ngIf="userHotelLength == 0 && (!userCancelledHotels || !userBookedHotels)">
...
</div>
<div *ngIf="userHotelLength != 0 && (userCancelledHotels || userBookedHotels)">
...
</div>
<div class="no-hotel-found" *ngIf="userHotelLength == 0">
...
</div>