@pbellini wrote:
Hello,
I am writing a fishing application that takes in some preferences the user selects and displays the data in the units selected. I am saving these user preferences in the Local Storage, and things seem to work fine in testing. I would like to know if there would be any issues with storing a small amount of data, just the user's preferences ( Metric/Imperial Celsius/Fahrenheit, etc...) in the Local Storage even though I am not connecting to any browser. The files themselves are on the client, but I would just like some confirmation on the functionality or someone who has some experience here.
.controller('SettingsCtrl', function($scope) {
myData = JSON.parse(localStorage.getItem('preference'));
if (myData === null || myData === undefined) {
$scope.data = {}
}
else {
$scope.data = myData
}
$scope.updateLocalStorage = function() {
localStorage.setItem( 'preference',JSON.stringify( $scope.data) );
}
})Thanks,
Peter
Posts: 1
Participants: 1