Using the following line :
<div class="card light-blue darken-4" [ngClass]="'card-grad-'+Math.floor(Math.random() * 10) + 1">
gives the following error:
ERROR TypeError: Cannot read property 'floor' of undefined
and component.ts.
How to resolve it ?
Even tried using decare var Math:any and also tried defining Math in the class but in vain.
Declare the Math in your component.ts
Math = Math;
or create a function that would calculate your value and bind that to ng-class
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