I've got a function using an API that redirects me to a callback URL. I then want to execute a function in my base javascript. I'm able to use window.opener to execute the function as long as I keep the function in a separate, non-angular, JS script. However, when I try to execute an angular function I just get an undefined error.
For clarity, here's what works:
callbackpage.html:
window.opener.inviteCallback();
index.html
<script>
function inviteCallback() {
console.log('Hey Im working')
};
</script>
... then onto some angular code
And now what doesn't work:
callbackpage.html:
window.opener.$scope.inviteCallback();
controller.js
.controller('MainCTRL', function($scope) {
var inviteCallback = function() {
console.log('Hey Im working')
};}
I'm using facebook connect using the Requests API.
Try this, add $window as dependency to controller.
myApp.controller('MyCtrl', function($scope, $window){
$window.inviteCallback = function() {
alert('hi');
}
});
And call inivteCallback using,
window.opener.inviteCallback();
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