title: Pass url params from flask to angular
body: <p>I have a flask route <code>search</code> that serves json search results and an <code>index</code> one that serves a page to search from, simplified as</p>
  
  <pre><code>@app.route('/search')
  def search():
      res = querydb(request.args)
      return jsonify(res)
  
  
  @app.route('/index')
  def index():
      return render_template('index.html')
  </code></pre>
  
  <p>In index.html, I have search forms linked to angular variables, and a button that queries <code>/search</code> using angular's <code>$http</code> and url params from the search forms.</p>
  
  <p>I would like the ability to additionally fetch initial results based on the url (for example, let the url <code>/index?color=red</code> load the <code>/index</code> page and fetch results from <code>/search?color=red</code> on load).</p>
  
  <p>To do this, I'm redefinig the jinja template tags as <code>&lt;%blah%&gt;</code> (to not interfere with angular's), and rendering the page with <code>render_template('index.html', color='red')</code>, with a snippet in the html like</p>
  
  <pre><code>&lt;div ng-controller="MainCtrl" ng-init="fetch('&lt;%color%&gt;')"&gt; &lt;/div&gt;
  </code></pre>
  
  <p>There mustbe a better way to send the params from flask to angular (trying <code>$routeParams</code> or <code>$location.search()</code> doesn't seem to work with flask, returning empty objects). Or should I be composing the views differently somehow?</p>