title: Angular.js and ng-switch-when - emulating enum
body: <p>I wanted to introduce some enum to my controller logic for some type safety, so for example I created something like this:</p>
  
  <pre><code>var app = angular.module('myApp', []);
  var StateEnum = Object.freeze({"login":1, "logout":2})
  function LoginCheckCtrl($scope) {
      $scope.stateEnum = StateEnum
      $scope.loginData = StateEnum.login
      $scope.login = function() {
          console.log($scope.loginData  ? 'logged in' : 'not logged in');
          $scope.loginData = StateEnum.logout;
      };
      $scope.logout = function() {
          console.log($scope.loginData ? 'logged in' : 'not logged in');
          $scope.loginData = StateEnum.login;
      };
  }
  </code></pre>
  
  <p>and in my example page I would have something like this:</p>
  
  <pre><code>&lt;div ng-controller="LoginCheckCtrl"&gt;
     &lt;div ng-switch on="loginData"&gt; 
        &lt;div ng-switch-when="stateEnum.login" ng-include="'login'"&gt;&lt;/div&gt;
        &lt;div ng-switch-when="stateEnum.logout" ng-include="'logout'"&gt;&lt;/div&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script type="text/ng-template" id="login"&gt;
      &lt;button ng-click="login()"&gt;Login&lt;/button&gt;
  &lt;/script&gt;
  
  &lt;script type="text/ng-template" id="logout"&gt;
      &lt;button ng-click="logout()"&gt;Logout&lt;/button&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>but <code>ng-switch-when</code> does not want to work. It only works if I substitute values in <code>ng-swith-when</code> manually with integers, for example 1,2.</p>
  
  <p>Here are fiddles to demonstrate this:</p>
  
  <p><a href="http://jsfiddle.net/jNxyE/3/" rel="nofollow noreferrer">http://jsfiddle.net/jNxyE/3/</a></p>
  
  <p><a href="http://jsfiddle.net/4Jg7M/2/" rel="nofollow noreferrer">http://jsfiddle.net/4Jg7M/2/</a></p>
  
  <p>now, as you can see, the first one clearly does not work, and second one works - meaning it changes button when button is clicked.</p>
  
  <p>The problem I think is this <code>var StateEnum = Object.freeze({"login":1, "logout":2})</code>.</p>
  
  <p>Is is possible to use my enum in my html so <code>ng-switch-when</code> will work properly (as in second fiddle)?</p>