Last active
August 29, 2015 13:57
-
-
Save DarcInc/9729521 to your computer and use it in GitHub Desktop.
Controller Invoking Modal View
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.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