I've got a pop-up window that calls a RESTful backend to do Oauth authentication, but when the result is returned, it displays the JSON in the popup window rather than closing the popup window and storing the JSON in a model. How do I fix this?
this.socialLogin = function(provider) {
var url = urlBase + '/' + provider,
width = 1000,
height = 650,
top = (window.outerHeight - height) / 2,
left = (window.outerWidth - width) / 2,
socialPopup = null;
$window.open(url, 'Social Login', 'width=' + width + ',height=' + height + ',scrollbars=0,top=' + top + ',left=' + left);
};
The situation described is likely not the best way to solve your problem in Angular. I am assuming that this is written inside of a controller. If so, making a call to a backend service is best done with the $http
service. To do so,
controller.js
angular.module('example')
.controller(['$scope', '$http', '$window', function($scope, $http, $window) {
$scope.socialLogin = function(urlEnd) {
$http.get(urlBase + '/' + urlEnd) // Should probably be posting here...
.then(function(res) { // Your JSON response here
$scope.doSomethingWithTheResponse(res.data);
}, function(err) { // Handle your error
$window.alert("We got us an error!\n" + JSON.stringify(err));
});
}
}])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With