how to get the value even page reload in angularjs

2019-09-08 12:02发布

hi all iam using angularjs service move data from one controller to another controller when i change dropdown i store value into service and bind the table through this service in another controller it's works fine but my need is after page reloading service value should be turn to null but i need last selected value even i stored into cookies but it's shows null help how to do this

service code

app.factory('StoreService', function() {
  return {
    storedObject:''
  };

});



app.controller('name', ['$scope', '$http', '$window', '$filter', '$cookieStore','StoreService', 
 function ($scope, $http, $window, $filter, $cookieStore,StoreService) {

  $scope.FacilityChange=function(){
        debugger;
            $scope.value = StoreService;


    };
});

Html

   <select id="MaterialFacility"  
               form="DistanceMatrixFormId" class="form-control"   
                 ng-change="FacilityChange(value.storedObject)"
             ng-model="value.storedObject" >

        <option value=''>Select</option>
        <option value=0>0</option>
        <option value=1>1</option>

   </select> 

0条回答
登录 后发表回答