当页面刷新时,我想将数据从范围返回到文本框值。我怎样才能只用更新按钮来做到这一点?
示例:Plunker
最佳答案
在您的 plunker 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>
关于javascript - 保存文本框数据并从本地存储返回 - angularJS -,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36010683/