JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app>
<div ng-controller="aController">
<div ng-class="getClass(texta)">{{texta}}</div>
</div>
<div ng-controller="aController">
<div ng-class="getClass(textb)">{{textb}}</div>
</div>
</div>
CSS
.error {
color: red;
}
JavaScript
function aController($scope) {
$scope.texta = "Some Text!";
$scope.textb = "Some text";
$scope.getClass = function(text) {
return text.slice(-1) === '!' ? 'error':'';
}
}