 <p>Use ng-class and call a function on your controller that does the check:</p> <pre><code>$scope.getClass = function(text) { return text.slice(-1) === '!' ? 'error':''; } </code></pre> <p><a href="http://jsfiddle.net/hHdfF/" rel="nofollow"><h2>Fiddle</h2></a></p> <p>Update: </p> <pre><code>&lt;div ng-class="(message.text.slice(-1) === '!' ? 'error':'')"&gt;{{message.text}}&lt;/div&gt; </code></pre>