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

Save textbox data and return from localstorage - angularJS -

本文关键字:存储 返回 angularJS 文本 数据 保存      更新时间:2023-09-26

当页面刷新时,我想将数据从范围返回到文本框值。如何仅使用更新按钮来做到这一点?

示例:普伦克

在 plunker 索引中进行此更改.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>