2

I am building a directive that handles out courses, part of this is saving course data in local storage so the user can resume.

When the data changes i call this function

function setLocalStorage(){
    if(!preview){
        $localStorage.scorm = scope.scorm
    }
}

I also call is when they first load up the course

My problem is that the data is not updated in local storage.

When i debug i can see that $localstorage.scorm is getting updated in chrome console but the data in the actual local storage is unchanged.

4

1 回答 1

1

通过使用 $apply 解决了它

function setLocalStorage(){
    if(!preview){
        scope.$apply(function () {
            $localStorage.scorm = scope.scorm;
        });
    }
}
于 2015-09-21T10:17:55.223 回答