我有一个名为item
的文本框,当页面加载时,我想从localstorage
获取一个值并将其放在文本框item
中,我稍后将其发送到数据库。
HTML:
<div ng-controller="newitem_ctrl">
<input name="item" type="text" id="item" placeholder="Name of Item" ng-model="item" required="required">
</div>
JS:
.controller('newitem_ctrl', function($scope,$http,$location,$ionicLoading,$ionicPopup, $timeout){
$scope.item = localStorage.getItem("shop_id")
$scope.insertnew = function() {
$ionicLoading.show({template: '<p>Adding...</p><ion-spinner></ion-spinner>'});
event.preventDefault();
$http.post("http://localhost/myweb/insert.php",
{'item':$scope.item,'quantity'})
.success(function(data,status,headers,config){
console.log(data)
{$ionicLoading.hide();}
}).error(function(error){
console.error(error);
});
}
})