Not getting much w/ the search. I found one kinda similar thread here but it didn't quite work for me.
The examples show that the Modal will get a separate controller. Looks something like this.
var app = angular.module('myApp', ['ngSanitize','angularModalService']);
app.controller('SampleController', ['$scope', function($scope) {
$scope.showAlert = function() {
ModalService.showModal({
templateUrl: "alertWindow.html",
controller: "AlertController",
inputs: {
title: "Add New Alert",
}
}).then(function(modal) {
modal.element.modal();
modal.close.then(function(result) {
$scope.result = "blah";
});
});
});
}]);
app.controller('AlertController', ['$scope', function($scope) {
$scope.close = function(result) {
close(result, 500);
};
}]);
The caveat I have is that I want the modal dialog to have some default values which are in SampleController. I read up on Services but I don't think that works here. inputs: { } in showModal() looks suspect, but I'm not exactly sure where to get it from once the modal window is shown. The other examples I've seen just bring up simple yes/no buttons or text inputs w/ empty default values.
According to the docs, you inject the inputs into the modal controller. Since title is the input you mentioned above, you would change your modal controller to:
app.controller('AlertController', ['$scope', 'title', function($scope, title) {
$scope.title = title;
$scope.close = function(result) {
close(result, 500);
};
}]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With