Сейчас я работаю над этим кодом, и я хотел бы использовать localStorage для сохранения состояния моих виджетов на моей панели инструментов, чтобы, когда пользователь возвращается в мое приложение, положение виджетов не менялось и сохранялось, но каждый раз, когда я обновляю браузер он возвращается к своему текущему состоянию scope.dashboards, которое я понятия не имею, как мне это исправить. Я использовал модуль ngStorage для localStorage.
var modInProgr = false;
$scope.$watch("dashboards['1'].widgets", function(newVal, oldVal) {
if (!modInProgr) {
modInProgr = true;
// modify dashboards
$scope.$storage = $localStorage;
$localStorage.sample = $scope.dashboards[1];
console.log($localStorage.sample);
}
$timeout(function() {
modInProgr = false;
}, 0);
$scope.dashboard = $localStorage.sample;
}, true);
// init dashboard
$scope.dashboard = $localStorage.sample;