title: Preset dropdown based on values of angular object
body: <p>I have a dropdown where the user selects one of three options. Based on their selection, a function is fired in the controller setting the value of two properties of an event object. </p>
  
  <p>This is the dropdown: </p>
  
  <pre><code>    &lt;select type="text" id="private_gallery" class="form-control" ng-model="gallerySetting" ng-options="setting for setting in gallery_settings" ng-change="setGalleryType(gallerySetting)"&gt;
      &lt;/select&gt;
  </code></pre>
  
  <p>This is the code from the controller that populates the dropdown: </p>
  
  <pre><code>$scope.gallery_settings = ['Public', 'Private', 'Hidden'];
  </code></pre>
  
  <p>When Public, Private or Hidden are selected, they are passed into the setGalleryType function which looks like this: </p>
  
  <pre><code>  $scope.setGalleryType = function (galleryType) {
      switch (galleryType) {
        case 'Public':
          $scope.event.private_gallery = 0;
          $scope.event.active = 1;
          break;
        case 'Private':
          $scope.event.private_gallery = 1;
          $scope.event.active = 1;
          break;
        case 'Hidden':
          $scope.event.private_gallery = 0;
          $scope.event.active = 0;
          break;
      }
    };
  </code></pre>
  
  <p>All of this works exactly as expected. The issue is when the application is reloaded. Since the gallerySetting model is not stored on the backend, the dropdown is no longer populated with the correct option. This is very confusing for the user and they assume that the setting wasn't saved properly. </p>
  
  <p>I need to somehow set the dropdown based on the <code>event.private_gallery</code> and <code>event.active</code> values. I tried the code below, but that causes scope issues and nothing after the dropdown is then recognized as Angular: </p>
  
  <pre><code>$scope.setGallerySetting = function() {
      if ($scope.event.private_gallery == 0 &amp;&amp; $scope.event.active == 1){
        return 'Public';
      } ...
    };
  
  $scope.gallerySetting = $scope.setGallerySetting();
  </code></pre>
  
  <p>Any thoughts on the based way to do this? </p>