Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not call methods of any angular service in the callback of any cross-domain-local-storage API #9

Open
bakkujp opened this issue Dec 20, 2014 · 3 comments

Comments

@bakkujp
Copy link

bakkujp commented Dec 20, 2014

My code:

$scope.login = function() {
.......
xdLocalStorage.setItem('authUser', angular.toJson(authUser), function(data) {
console.log(data.success);
if (data.success) {
console.log('Your data has been successfully stored.');
$location.path('/home');
} else {
console.log('Ops, could not store your data.');
}
});
}

BUT

$location.path('/home'); is not run at the first time clicking login but second times $location.path('/home'); is run

@ofirdagan
Copy link
Owner

Hi bakkujp, I had a bug in xdLocalStorage but It's fixed now..
Please run 'bower update' and let me know if you're still having problems.

@bakkujp
Copy link
Author

bakkujp commented Dec 21, 2014

Hi,

I think that in case of "xdLocalStorage was already initialized!", you should permit communicating with the cross-domain with the existing xdLocalStorage. Currently, if encountering this case, all API seem to be NOT avaiable !!!! Maybe it comes from Angular router. If I do workaround your code in the function init

// if (wasInit) {
//   console.log('xdLocalStorage was already initialized!');
//   return;
// }

var iframeWrapper = document.getElementById("iframe-wrapper");
if (iframeWrapper != null) iframeWrapper.remove() ;

var temp = document.createElement('div');
temp.setAttribute("id", "iframe-wrapper");

Then, everything is ok !!!!

Br,

Bach (bakkujp)

@ofirdagan
Copy link
Owner

Hi Bach, Sorry for the long delay. I can't reproduce this scenario.

Can u please provide a snippet (plnkr/ jsFiddle) that reproduces the error?

10x!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants