I'm using the Angular UI modal directive: http://angular-ui.github.io/bootstrap/
I'm trying to pass a string from my modal open() function to my modal controller via the resolve object. I feel like I'm doing the right thing, but somehow it isn't working.
Modal open() function:
$scope.showCommentModal = function () {
var modalInstance = $modal.open({
templateUrl: "templates/text-entry-modal.html",
controller: "TextEntryModalCtrl",
resolve: {
value: function () {
alert("VALUE");
return "Hello"
}
}
});
};
Modal controller:
.controller("TextEntryModalCtrl", ["$scope", "$modalInstance", function ($scope, $modalInstance, value) {
alert(value);
$scope.value = value;
$scope.cancel = function () {
$modalInstance.dismiss("cancel");
};
}]);
The alert in the open function shows every time, right before the alert from the controller, so it's doing something, but when it gets to the controller, value is undefined.
One thing to note is that these controllers are not global variables. The example in the link above is using those, but that's not best practice for us.
Also, I have read this post: Angular-ui modal, sending data into modal controller from $http
I feel like this is very close to the answer I'm looking for, but I don't think I'm waiting on a promise to resolve in this case, am I? As far as I can tell, our implementations are very similar, but again I'm not using global variables but they are. Or maybe I just don't understand what's actually going on here. Of course, I don't have enough points to just ask that, so here I am...