Consider this example:
Main.html:
<html>
<body>
<script>
angular.module('app', ['ngRoute']).config(function($routeProvider) {
$routeProvider
.when('/page1', { templateUrl : 'page1.html' })
.when('/page2', { templateUrl : 'page2.html' })
})
</script>
<a href="#page1/">Page 1</a>
<a href="#page2/">Page 2</a>
<div ng-view></div>
</body>
</html>
page1.html
Page 1: <input type="text">
page2.html
Page 2: <input type="text">
DEMO: http://plnkr.co/edit/1BfO7KkHeMD3EpsULNGP?p=preview
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.