I am working on ionic framework.I want to know how to insert text into input label from local storage.I want to add text in username input box if data is stored locally.Here goes the code.
In login.html
<label class="item item-input item-stacked-label">
<span class="input-label">Username</span>
<input type="text" ng-model="xxx.user" id="userInput" placeholder="Email or Phone">
</label>
In controller .js
var loadData1 =window.localStorage.getItem("data");
console.log(loadData1);
var userInput=document.getElementById("userInput");
if (window.localStorage.getItem("data") !== null){
userInput.innerHTML =loadData1;
console.log(window.localStorage.getItem("data"));
};
add the data to the model of the input.
for ex:
$scope.xxx = {'user': '' , 'password': ''};
var loadData1 =window.localStorage.getItem("data");
console.log(loadData1);
if (loadData1 != null){
$scope.xxx.user = loadData1;
console.log( $scope.xxx.user);
};