AngularJS Example

by gogirl

HTML

<div ng-app="">
  <div ng-controller="Ctrl">
    <select ng-model="selection" ng-options="item for item in items">
    </select>
    <tt>selection={{selection}}</tt>
    <hr/>
    <div ng-switch on="selection" >      
          <span ng-switch-when="">This string is empty</span>
        <span ng-switch-when='blue' style="color:blue">This string is blue</span>
          <span ng-switch-default>This string is not empty</span>
    </div>
  </div>
</div>

CSS

</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ --> 
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
<style>
.ng-invalid { border: 1px solid red; }

JavaScript

//what is an appropriate usage of ng-default?
function Ctrl($scope) {
    debugger;
    $scope.items = ['','blue', 'not empty'];//use an array
    $scope.selection = $scope.items[0];// first
}