javascript - Get JSON Result from popup window. Angular.JS -
i've got pop-up window calls restful backend oauth authentication, when result returned, displays json in popup window rather closing popup window , storing json in model. how 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 not best way solve problem in angular. assuming written inside of controller. if so, making call backend service best done $http
service. so,
controller.js
angular.module('example') .controller(['$scope', '$http', '$window', function($scope, $http, $window) { $scope.sociallogin = function(urlend) { $http.get(urlbase + '/' + urlend) // should posting here... .then(function(res) { // json response here $scope.dosomethingwiththeresponse(res.data); }, function(err) { // handle error $window.alert("we got error!\n" + json.stringify(err)); }); } }])
Comments
Post a Comment