generator-angular-fullstack icon indicating copy to clipboard operation
generator-angular-fullstack copied to clipboard

Modal Service

Open Hamatek opened this issue 12 years ago • 28 comments

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

Hamatek avatar Sep 22 '14 08:09 Hamatek

Thanks!

rmindigo avatar Jan 22 '16 19:01 rmindigo

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');

tylerdmace avatar Jan 25 '16 08:01 tylerdmace

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 avatar Jan 25 '16 13:01 kingcody

@kingcody Thank you! This is exactly what I was missing -- feel stupid for not having checked there first.

tylerdmace avatar Jan 25 '16 17:01 tylerdmace

@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.

msjoshi avatar Jan 27 '16 05:01 msjoshi

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?

msjoshi avatar Jan 28 '16 03:01 msjoshi

I'd put validation logic in your click() function;

tylerdmace avatar Jan 28 '16 19:01 tylerdmace

@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.

msjoshi avatar Jan 30 '16 01:01 msjoshi