【发布时间】:2016-12-21 19:38:16
【问题描述】:
我正在使用 angularjs 制作计时器应用程序,单击时间列表后计数器开始,可以通过单击添加计时器来添加时间列表中的新时间(弹出窗口打开,然后使用时间选择器选择时间)。 选择的时间被添加到列表中以及单击 OK 按钮的本地存储。 但是当页面重新加载时,不会显示时间列表中新添加的时间,而是驻留在 localStorage 变量中(即 timeListDetails)。 我希望在添加新计时器时显示它。
获取和设置本地存储值的代码:
$scope.getStoredTimeList = function(){
timeList = JSON.parse(localStorage.getItem("timeListDetails")) || [];
if(timeList != null){
timeList.push({"hour":hour,
"minutes":minutes,
"seconds":seconds,
"convertedSec":convertedSec,
"timeFlag": true});
}
$scope.timeList = $scope.timeList.concat(timeList).unique();
localStorage.setItem("timeListDetails", JSON.stringify(timeList));
}
我已经完成了我的完整示例。 Clock Application review
请告诉我解决方法。
【问题讨论】:
标签: angularjs html local-storage html-framework-7