title: POSTing form data via Angular to a Flask web application and returning newly rendered template
body: <p>i have the following AngularJS, HTML and Flask code.  i am able to select from a dropdown, and submit the value to the web server.  the web server is printing the selection, but i am wondering how to return the newly rendered template <strong>report_filter.html</strong> with the provided <strong>serial_no</strong> value.  i am displaying this value elsewhere in the page.  the post request is getting sent, but the new page is not rendering.  how should this intention be accomplished?  thanks!</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form ng-submit="printReport(selectedDevice)" name="deviceSelectionForm" novalidate&gt;
      &lt;legend&gt;Select Device&lt;/legend&gt;
      &lt;label for="device_selection"&gt;serial number&lt;/label&gt;
      &lt;select ng-model="selectedDevice" class="form-control" id="device_selection" ng-options="DeviceSerialNo.device_id for DeviceSerialNo in DeviceSerialNos"&gt;&lt;/select&gt;
      &lt;button class="btn btn-primary" type="submit" ng-disabled="deviceSelectionForm.$invalid"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>AngularJS</strong></p>
  
  <pre><code>var dlrApp = angular.module('dlrApp', []);
  
  dlrApp.controller('MainCtrl',
      function ($scope, $http) {
          $scope.DeviceSerialNos = [
              {% for device_id in device_id_rows %}
                  {device_id: "{{device_id}}"},
              {% endfor %}
          ];
  
          $scope.selectedDevice = {};
  
          $scope.printReport = function(filterParams) {
              $http.post("dataset", JSON.stringify(filterParams), null)
              .success(function (data, status, headers, filterConfig)
              {
                  $scope['id'] = data;
              })
              .error(function (data, status, headers, filterConfig)
              {
                  $scope['id'] = "SUBMIT ERROR";
              });
          }
      }
  );
  </code></pre>
  
  <p><strong>Flask</strong></p>
  
  <pre><code>@app.route('/', methods=['GET', 'POST'])
  @app.route('/dataset', methods=['GET', 'POST'])
  def report_filter():
      device_id_rows = [800, 801, 802, 803, 804]
      json_data = request.get_json()
  
      if json_data is not None and "device_id" in json_data:
          serial_no = json_data["device_id"].__str__()
      else:
          serial_no = "unknown"
  
      print serial_no
      return render_template('report_filter.html', device_id_rows=device_id_rows, serial_no=serial_no)
  </code></pre>