 <p>Try this code :</p> <pre><code>&lt;div ng-init="setFromDiv = 'green'" ng-click="setFromDiv = 'green'"class="box green"&gt;&lt;/div&gt; &lt;div ng-click="setFromDiv = 'blue'" class="box blue"&gt;&lt;/div&gt; &lt;div ng-click="setFromDiv = 'red'" class="box red"&gt;&lt;/div&gt; &lt;div ng-click="setFromDiv = 'yellow'" class="box yellow"&gt;&lt;/div&gt; &lt;div class="mainBox" ng-class="setFromDiv"&gt;&lt;/div&gt; </code></pre>