Angular Box Color Exercise
I would pass the className to the logClass method. Because how you wrote the method you enforce that the color name is the second class applied on the control. This is very fragile, as there is no direct relation between the class order in the an element and the result apply to them. So I would do:

vm.logClass = function(className) {
...
}
//template
 &lt;div ng-click="vm.logClass('green')" class="box green"&gt;&lt;/div&gt;
    &lt;div ng-click="vm.logClass('blue')" class="box blue"&gt;&lt;/div&gt;
    &lt;div ng-click="vm.logClass('red')" class="box red"&gt;&lt;/div&gt;
    &lt;div ng-click="vm.logClass('yellow')" class="box yellow"&gt;&lt;/div&gt;