Modal Service
I noticed there is a modal service in the latest version of the generator, but i couldn't find any example to see how to use it, I mean what should I I do once I call the modal service in my controller ?
Is there anyone kind enough to give me an explanation regarding this new service and how to use it ?
Cheers
Thanks!
Anyone got implementation details on the modal scope object that gets passed into openModal() as the first argument? I am wanting to use HTML instead of 'text' with my buttons (for span elements and glyphicons) but without more information on what is supported there, I am steering blind. Below is a code block relevant to my question -- any help or suggestions are appreciated!
deleteModal = openModal({
modal: {
formData: formData
dismissable: true,
title: 'Confirm Delete',
html: '<p>Are you sure you want to delete <strong>' + name + '</strong> ?</p>',
buttons: [{
classes: 'btn-danger',
text: 'Delete',
click: function(e) {
deleteModal.close(e);
}
}, {
classes: 'btn-default',
text: 'Cancel',
click: function(e) {
deleteModal.dismiss(e);
}
}]
}
}, 'modal-danger');
button.text is used in the modal template. If you would like to use html, simply change the template like so:
- button.btn(ng-repeat='button in modal.buttons', ng-class='button.classes', ng-click='button.click($event)', ng-bind='button.text')
+ button.btn(ng-repeat='button in modal.buttons', ng-class='button.classes', ng-click='button.click($event)', ng-bind-html='button.text')
@kingcody Thank you! This is exactly what I was missing -- feel stupid for not having checked there first.
@haverchuck Thanks for asking. I had moved on from using the modal service after trying last time. I followed the solution provided by @MagRelo and it worked like a charm. Thanks @MagRelo.
In the modal form how can I perform validation on this ng-click='button.click($event)' event? I'm not using a submit button so the form should be validated when the OK button is pressed. Any ideas?
I'd put validation logic in your click() function;
@tylerdmace In the click() function formData only contains the data I entered in the input fields. I wanted to check if the form is valid using formData.$valid and that comes undefined. I wanted to set formData.$submitted = true so that the form is validated.