title: How to programmatically select ng-option value?
body: <p>I have a view that is filled with dropdownlists to filter a report. I also have a view of saved filters that are displayed as links. When a user clicks on their saved filters, I want the appropriate values of the dropdownlists to be selected. The drop downs are being populated properly. On the saved filter link there is an <code>ng-click</code> that will call a function that iterates through the collection of saved filter values and automatically selects the correct one. I cannot figure out how to programmatically set the selected option. Any help is much appreciated!</p>
  
  <pre><code>&lt;select uid="locSelect" 
          class="span12" 
          ng-model="reportDetail.selectedLoc" 
          ng-options="loc.dbid as loc.serviceName for loc in reportDetail.locList | orderBy:'name'"&gt;
      &lt;option uid="unselectedLocOption" value=""&gt;-- Select One --&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Here is the list of saved filters:</p>
  
  <pre><code>&lt;div class=" well fixed-search" style="overflow-x: hidden;overflow-y: auto;"&gt;
  &lt;div class="well-header"&gt;
      Saved Filters
  &lt;/div&gt;
  &lt;div ng-if="!hasSavedFilters"&gt;
      &lt;span&gt;No saved filters&lt;/span&gt;
  &lt;/div&gt;
  &lt;ul ng-if="hasSavedFilters" class="nav nav-list dashboard-list"&gt;
      &lt;li ng-repeat="filter in reportDetail.savedFilters"&gt;
          &lt;a uid="savedFilter" href="" ng-click="reportDetail.loadSavedFilters(filter.filters)"&gt;
              &lt;span ng-bind="filter.title"&gt;&lt;/span&gt;
          &lt;/a&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is my controller</p>
  
  <pre><code>(function(){
  'use strict';
  
  var ReportDetailController = function(ReportsService, $scope){
      var _locList = {};
      var _hospitalStatusList = {};
      var _providerStatusList = {};
      var _savedFilters = [];
      var _sourceTypeList = {};
      var _dateRangeList = {};
  
      var _init = function(){
          ReportsService.getCurrentReportSavedFilters().then(function(data){
              $scope.reportDetail.savedFilters =data;
              $scope.hasSavedFilters = ReportsService.hasSavedFilters();
          });
  
          ReportsService.getLOCListForDDL().then(function(data){
              $scope.reportDetail.locList = data;
              //$scope.reportDetail.selectedLoc = $scope.reportDetail.locList[0];
          });
  
          ReportsService.getSelectListData()
              .then(function(data){
                  $scope.reportDetail.sourceTypeList = data.CONNECTION_TARGET_STATUS;
                  $scope.reportDetail.hospitalStatusList = data.CONNECTION_SOURCE_STATUS;
              });
          ReportsService.getDateRangesForDDL()
              .then(function(data){
                  $scope.reportDetail.dateRangeList = data;
              });
  
          $scope.reportDetail.providerStatusList = ReportsService.getProviderStatusForDDL();
  
  
      };
  
  
  
      var _loadSavedFilters = function(filters){
          for(var i = 0, l = $scope.reportDetail.locList.length; i&lt;l; i++){
              if($scope.reportDetail.locList[i].serviceName == filters.levelOfCare){
                   $scope.reportDetail.selectedLoc = $scope.reportDetail.locList[i];
                  console.log($scope.reportDetail.selectedLoc);
              }
          }
      }
  
      var _isActive = function(filter){
          for(var i = 0, l = $scope.reportDetail.savedFilters.length; i&lt;l; i++){
              if(filter.title == $scope.reportDetail.savedFilters[i].title){
                  return true;
              }
              return false;
          }
      }
  
      var _generateReport = function(){
          return ReportsService.generateReport();
      };
  
      $scope.reportDetail = {
          init: _init,
          selectedLoc: null,
          isActive: _isActive,
          locList: _locList,
          selectedHospitalStatus: 'NOTIFIED',
          hospitalStatusList: _hospitalStatusList,
          selectedProviderStatus: 'NEW',
          providerStatusList: _providerStatusList,
          selectedSourceType: 'CONNECTED',
          sourceTypeList: _sourceTypeList,
          selectedDateRange: '',
          dateRangeList: _dateRangeList,
          savedFilters: _savedFilters,
          loadSavedFilters: _loadSavedFilters,
          generateReport: _generateReport
      };
  
      $scope.reportDetail.init();
  };
  
  app.controller('ReportDetailController', ['ReportsService', '$scope',  ReportDetailController]);
  })();
  </code></pre>