javascript - Ng-Click remember radio button selection -


i'm trying create form on multiple views. how make if user goes back, choice still stored?

view 1

   <div>                 <em style="font-size: 2.75em">{{message}}</em>             </div>             <br /><br />             <p>what color like?</p>             <br /><br />             <div class="col-xs-offset-4">                 <form role="form" >                     <div class="radio">                         <label><input type="radio" name="optradio" value="yellow" id="yellow">yellow</label>                     </div>                     <div class="radio">                         <label><input type="radio" name="optradio" value="blue" id="blue">blue</label>                     </div>                     <div class="radio">                         <label><input type="radio" name="optradio" value="green" id="green">green</label>                     </div>                 </form>             </div>              <br /><br />              <div ng-controller="mycontroller" >                 <button type="button" class="btn btn-default" ng-click="mydata.doclick()">next </button>             </div> 

script.js

scotchapp.controller("mycontroller", function($scope) {     $scope.mydata = {};     $scope.mydata.doclick = function() {       parent.location='#q_two';     } } ); 

any | place read more | or way think appreciated.

thanks.

you maintain service stored changes, , getter & setter

service

app.service('data', function() {     this.data = {         radiovalue: false;     };     this.getradiovaluedata = function() {         return this.data.radiovalue;     };     this.setradiovaluedata = function(val) {         this.data.radiovalue = val;     }; }); 

code

scotchapp.controller("mycontroller", function($scope, data) {     $scope.data = data;     $scope.mydata.doclick = function() {         $scope.data.setradiovaluedata();     }; }); 

in other controller value of change radio button $scope.data.getradiovaluedata();


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -