Wednesday, 26 April 2017

Retain the dropdown value after the page is refresh or move to another page in angularjs

let me explain my scenario. I am having the dropdownlist in my master page. if changed dropdownlist the data are changed depend upon the dropdownlist value.
If i refreshed my page or moved to another page the dropdownlist will clear automatically.

I want to retain the dropdownlist value after refresh the page or moved to another page.

I tried like this but this is not help ful.

HTML

<select id="Facility_ID" required typeof="text" name="Facility Name" ng-options="Role.FacilityName for Role in Roles"
                    form="DistanceMatrixFormId" class="form-control" ng-model="Role._id" ng-selected="getFacilityID(Role._id.FacilityName)">
            </select>

Controller.js

 $scope.getFacilityID = function (data) {
     localStorage.setItem("FacilityName", data);
     var getfacility = localStorage.getItem("FacilityName");
 }

i refered this link but it is not help ful

I don't know how to retain the value. can any one fixed me.



via Vinoth

No comments:

Post a Comment