简体   繁体   English

保存文本框数据并从localstorage返回-angularJS-

[英]Save textbox data and return from localstorage - angularJS -

When page refresh I want to return data from scope to textbox value. 页面刷新时,我想将数据从范围返回到文本框值。 How can I do it with only update button? 仅使用更新按钮怎么办?

Example: Plunker 示例: Plunker

Make this changes in your plunker index.html 在您的监听器index.html中进行此更改

<script>


angular.module("example", ["ngStorage"])
.controller("ExampleController", function($scope, $localStorage) {

$scope.save = function() {
$localStorage.message = $scope.zafer;
console.log(zafer);
}

$scope.load = function() {
$scope.zafer = $localStorage.message;

} 

})

</script>
</head>
<body ng-app="example">
<div ng-controller="ExampleController" ng-init="load()">

<input type="text" ng-model="zafer">

<button ng-click="save()">Update</button>



</div>
</body>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM