Skip to content

Instantly share code, notes, and snippets.

@DarcInc
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarcInc/9729521 to your computer and use it in GitHub Desktop.
Save DarcInc/9729521 to your computer and use it in GitHub Desktop.
Controller Invoking Modal View
myApp.controller("RegularController", ["$scope", "$modal", function($scope, $modal) {
$scope.open = function() {
var modalInstance = $modal.open({
templateUrl: "some-modal-dialog.html",
controller: MyModalInstanceController,
scope: $scope
});
modalInstance.result.then(
function(result) {
//Happy path - The user clicked okay.
}, function(err) {
//Sad path - The user probably canceled.
});
}
}]);
var MyModalInstanceController = ["$scope", "$modalInstance", function($scope, $modalInstance)
{
$scope.clickedOkay = function() {
//Happy path.
$modalInstance.close("some useful data");
// Calling $modalInstance.dismiss() takes us down the sad path.
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment