title: How can I make the selection of a value from a select list populate options in a second select list using AngularJS
body: <p>I am using the following HTML and javascript to populate a select box:</p>
  
  <pre><code>   &lt;select data-ng-model="selectedTestAccount" data-ng-options="item.Id as item.Name for item in testAccounts"&gt;
        &lt;option value=""&gt;Select Account&lt;/option&gt;
     &lt;/select&gt;
  
     &lt;script type="text/javascript"&gt;
          angular.module('test', []).controller('TestCtrl', function ($scope, $http) {
              $scope.selectedTestAccount = null;
              $scope.testAccounts = [];
  
              $http({
                  method: 'GET',
                  url: '/Admin/Exams/GetTestAccounts',
                  params: { applicationId: 3 }
              }).success(function (result) {
                  $scope.testAccounts = result;
              });
          });
          angular.bootstrap(angular.element("body")[0], ["test"]);
      &lt;/script&gt;
  </code></pre>
  
  <p>This works fine but now I need to have another select list that chooses subjects when a user selects a value from the first select list. I think this is the way I would set up the selects and get the data from the server:  </p>
  
  <pre><code>   &lt;select data-ng-model="selectedTestAccount" data-ng-options="item.Id as item.Name for item in testAccounts"&gt;
        &lt;option value=""&gt;Select Account&lt;/option&gt;
     &lt;/select&gt;
     &lt;select data-ng-model="selectedSubject" data-ng-options="item.Id as item.Name for item in subjects"&gt;
        &lt;option value=""&gt;Select Subject&lt;/option&gt;
     &lt;/select&gt;
     ...
     $http({
        method: 'GET',
        url: '/Admin/GetSubjects',
        params: { testAccountId: selectedTestAccount }
     }).success(function (result) {
        $scope.subjects = result;
     });
  </code></pre>
  
  <p>How can I make it so that when the user selects a value from the first select box then it will go to the database
  and select subjects and populate the second select box.</p>