title: Keep form input on route change AngularJS
body: <p>Consider this example:</p>
  
  <p>Main.html:</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;script&gt;
              angular.module('app', ['ngRoute']).config(function($routeProvider) {
                  $routeProvider
                      .when('/page1', { templateUrl : 'page1.html' })     
                      .when('/page2', { templateUrl : 'page2.html' })
              })
          &lt;/script&gt;
  
          &lt;a href="#page1/"&gt;Page 1&lt;/a&gt;
          &lt;a href="#page2/"&gt;Page 2&lt;/a&gt;
  
          &lt;div ng-view&gt;&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>page1.html</p>
  
  <pre><code>Page 1: &lt;input type="text"&gt;
  </code></pre>
  
  <p>page2.html</p>
  
  <pre><code>Page 2: &lt;input type="text"&gt;
  </code></pre>
  
  <p>DEMO: <a href="http://plnkr.co/edit/1BfO7KkHeMD3EpsULNGP?p=preview" rel="nofollow">http://plnkr.co/edit/1BfO7KkHeMD3EpsULNGP?p=preview</a></p>
  
  <p>Click on one of the links Page 1 or Page 2. Input something in the field and then click on the opposite link. The field is cleared. Is there a way to keep input? This is very useful if a user is posting a comment, but has to login before the changes can be saved. The user will be redirected to a login page, and after login be redirected back to the input page. </p>