Dear Srikar Phani Kumar Marti, I have gained a better understanding of [class] and [ngClass] thanks to your guidance. Here is how I implemented it:
<i
[class.text-success]="CardData.quantity > 1 || _ProductQuantity > 1"
[ngClass]="{'fa': true,'far fa-check-square': CardData.quantity > 1 ||
_ProductQuantity > 1, 'far fa-times-circle': CardData.quantity < 1 ||
_ProductQuantity < 1}"
[class.text-danger]="CardData.quantity < 1 || _ProductQuantity < 1"
>
{{CardData.quantity < 1 || _ProductQuantity < 1 ? "Cannot
Ship" : "Free
Shipping"}}
</i>
///// By Srikar
// Please remember you can do this too to keep the HTML clean and neat.
// in component.ts file, create a variable for the classes
conditionalClasses = {
'fa': true,
'far fa-check-square': CardData.quantity > 1 || _ProductQuantity > 1,
'far fa-times-circle': CardData.quantity < 1 || _ProductQuantity < 1
}
// in HTML file, you can do this too!
<i
[class.text-success]="CardData.quantity > 1 || _ProductQuantity > 1"
[ngClass]="conditionalClasses"
[class.text-danger]="CardData.quantity < 1 || _ProductQuantity < 1"
>
{{
(CardData.quantity < 1 || _ProductQuantity < 1)
? "Cannot Ship"
: "Free Shipping"
}}
</i>