I am looking to implement a method for adding a CSS class to the text color of a message based on the response.
Currently, I achieve this by:
if (response.data.status == 201) {
angular.element(document.getElementById("msg")).addClass("text-green");
$scope.msg = 'Users created for Meeting ' + r.id
+ ' on ' + $filter('date')(r.updated_at, 'M/d/yyyy')
+ ' at ' + $filter('date')(r.updated_at, 'HH:mm:ss');
console.log("Status Code= " + response.data.status + ", Status Text= " + response.data.message);
return true;
}
else {
angular.element(document.getElementById("msg")).addClass("text-red");
$scope.msg = r.message;
angular.element("#meeting-id").focus()
console.log("Status Code= " + response.data.status + ", Status Text= " + response.data.message);
return false;
}
Although it is effective, I now have two classes that can be applied to success and error messages. I am seeking guidance on how to add these classes in order to remove the inline style attribute that changes the text color to red or green.
The class names are:
• Success: “text-green”
• Error: “text-red”
What would be the right approach to accomplish this?
Any assistance is highly appreciated.
Thank you, Erasmo