0

I am having request page with below tags.

<p>This page demonstrates 
    <span class="text-danger">nested</span> views.  </p>       
<a ui-sref=".additem" class="btn btn-danger">Add Item sref</a>
<a ui-sref="cloneitem" class="btn btn-primary">Clone Items</a>
<input type="text"/>

and I type something in the textbox "Sample text"

If I click Clone Items it will redirect to clone.html and the content

<a ui-sref="back" class="btn btn-danger">Back to Request Form</a>
<a ui-sref="clone"  class="btn btn-primary">Clone</a>

If I click back it is showing request page but the text box is cleared.

I have added the below in app.js

routerApp.run(
    ['$rootScope', '$state', '$stateParams',
    function ($rootScope, $state, $stateParams) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
    }
]);

But I am not sure how to maintain state using sref and how to pass parameters.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
user18508
  • 21
  • 1
  • 3
  • 1
    There are many possibilities to keep input value: you could use a MainController above all your states and in its $scope attach a property which is bind (ng-model) to the input element; or another way is to bind the input to $rootScope property. – beaver Dec 22 '15 at 12:29
  • On how to pass parameters you could see this post: http://stackoverflow.com/questions/25647454/how-to-pass-parameters-using-ui-sref-in-ui-router-to-controller – beaver Dec 22 '15 at 12:30
  • ok wat if, not only single text box value i want entire page with all its input to maintain. i want something like viewstate in .net . back and forth navigation values will not get vanished – user18508 Dec 24 '15 at 05:42
  • Instead of using simple values as a model you could use an associative array to which bind all your input (one property for each input in the page/form) – beaver Dec 24 '15 at 06:14

0 Answers0