Skip to content

Instantly share code, notes, and snippets.

@enapupe
Created September 29, 2014 15:10
Show Gist options
  • Save enapupe/a10414d8234a55455dfe to your computer and use it in GitHub Desktop.
Save enapupe/a10414d8234a55455dfe to your computer and use it in GitHub Desktop.
PopUp opener directive for angularjs
"use strict";
myApp.controller("SomeCtrl", function($scope){
$scope.callback = function(){
// do something
};
$scope.url = "http://some/popup";
});
myApp.directive("popup", function($window){
return {
restrict: "AE",
scope: {
popup: "=",
dimensions: "@",
callback: "="
},
link: function(scope, elem){
$window.comeBack = function(){
scope.callback();
};
elem.on("click", function(e){
var authwindow = $window.open(scope.popup, "popup", scope.dimensions);
authwindow.focus();
});
}
};
});
<button popup="url" callback="callback" dimensions="width=500,height=300">ExamplePopUp</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment