I have defined a few style classes in my stylesheet as shown below:
.left-align{
/* some styles here */
}
.right-align{
/* some styles here */
}
.validate-error{
/* some styles here */
}
Depending on the type of data, I need to align the content either left or right. Additionally, I want to validate the data in the control and if validation fails, I need to append the validate-error
class to the ng-class
. I have researched various Stack Overflow threads, articles, and QA sites discussing multiple conditions in ng-class
, but so far nothing has worked for my specific scenario. I have attempted the following based on the references:
ng-class="{!vm.validate()?'validate-error': vm.isNumericField?'right-align':'left-align'}"
However, this approach does not align the content to the right even when isNumericField
is true if validate()
returns false.
In summary, I need to apply the left-align
or right-align
class depending on the value of the isNumericField
property, and include the validate-error
class if validate()
returns false.
"isNumericField?{'left-align':'right-align'} + 'validate-error':validate()"
If anyone knows of a way to achieve this, please let me know: