Skip to content

bind question ... or bug #260

@rares-lupascu

Description

@rares-lupascu

Hi

Can anyone tell me why both scope and localstorage values are not synced?

$scope._emptyCredentials = {
    '_uid': null,
    '_token': null,
    '_ts': null
  };
  $scope.user = {
    email: '',
    password: ''
  };
  $scope.flags = {
    bLoginFailed: false,
    bIsAuthenticated: false
  };
  localStorageService.set('credentials', $scope._emptyCredentials);
  $scope.unbindCredentials = localStorageService.bind($scope, 'credentials');
  alert(JSON.stringify($scope.credentials));
  alert(JSON.stringify(localStorageService.get('credentials')));
  $scope.credentials = {
    '_uid': 1,
    '_token': 'aaa',
    '_ts': new Date()
  };
  $timeout(function() {
    alert(JSON.stringify($scope.credentials));
    alert(JSON.stringify(localStorageService.get('credentials')));
    $scope.credentials = $scope._emptyCredentials;
    $timeout(function() {
      alert(JSON.stringify($scope.credentials));
      alert(JSON.stringify(localStorageService.get('credentials')));
    });
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions