0

我是 angular.js 的新手。我正在尝试使用ngStorage在我的应用程序中为特定计数器提供 sessionStorage

以下方法返回评论的具体计数器。我想使用 sessionStorage 存储和读取这个计数器。

var commentCounter = function () {
    var commentCounter = {
        incrementCount:function () {
            var currentCount = myCounter.readPageViewCount();
            currentCount++;
            myCounter.recordPageViewCount(currentCount);
        },
        recordPageViewCount:function (pageViewCount) {
            var lastRecorded = new Date().toUTCString();

             // Need to record the counter
        },
        readPageViewCount:function () {
            var sessionCounter = 0;
            // Read counter from session
            return sessionCounter;
        }
    }
    return commentCounter;
}

任何人都可以帮助我以正确的方向处理这个 sessionStorage 吗?

4

0 回答 0