Created
September 29, 2014 15:10
-
-
Save enapupe/a10414d8234a55455dfe to your computer and use it in GitHub Desktop.
PopUp opener directive for angularjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
myApp.controller("SomeCtrl", function($scope){ | |
$scope.callback = function(){ | |
// do something | |
}; | |
$scope.url = "http://some/popup"; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
} | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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