How to retrieve values from a ngdialog?

1

I'm having difficulty working with ngdialog , could someone please tell me how to retrieve data from a ng-dialog template?

below the code I'm working on

   ngDialog.open({
                            template: "\
                            <div ng-controller='EstadosController'> \
                            <div style=\"text-align: center; font-weight: bold;font-size: 18px; \">Informações do documento</div>\
                            <div style=\"margin:15px;\"> \
                            <label style=\"font-weight: normal;\">Data Documento</label> \
                            <div> \
                            <input style=\"width:250px;\" type=\"date\" label=\"Data Documento\" ng-model='item.dataDocumento' > \
                            </div>\
                            </div> \
                            <div style=\"margin:15px;\"> \
                            <label style=\"font-weight: normal;\">Tipo Documento</label> \
                            <div> \
                             \ <select ng-model='item.tipoDocumento' ng-options=\"item as item.label for item in items track by item.id\" ></select>\
                            </div>\
                            </div> \
                            <div style=\"margin:15px;\"> \
                            <label style=\"font-weight: normal;\">Descrição Documento</label> \
                            <div> \ <textarea  ng-model='item.descricao' row=\"30\" style=\"width: 250px; height:150px\"> </textarea> \
                            </div> \
                            </div> \
                            <div style=\"text-align:center\"> \
                                <input style='margin:5px;    width: 100px;' type='button' value='SALVAR' ng-click=\"closeThisDialog('SALVAR',item)\"> \
                                <input style='margin:5px;    width: 100px;' type='button' value='CANCELAR' ng-click=\"closeThisDialog('CANCELAR',item)\"> \
                            </div>\
                            </div>",
                            plain: true,
                            closeByNavigation: false,
                            closeByDocument: false,
                            closeByEscape: true,
                            showClose: true,
                            className: 'ngdialog-theme-plain',
                            preCloseCallback: function (value, item) {
                                if (value == 'SALVAR') {
                                    var params = {};
                                    params.dataDocumento = item.dataDocumento;
                                    params.tipoDocumento = item.tipoDocumento;
                                    params.descricao = descricao;
                                }

                            }

                        });
    
asked by anonymous 04.09.2018 / 21:26

1 answer

1

First it is interesting not to pass the template by means of a string, it is difficult to maintain and display the code, a more interesting example would be this:

<script type="text/ng-template" id="templateId">
    <h1>Template heading</h1>
    <p>Content goes here</p>
</script>

ngDialog.open({ template: 'templateId' });

In addition it is possible to reference a controller in the ngDialog configuration, which together with the example above would be:

ngDialog.open({ template: 'templateId', controller: 'ExemploController' });

So the form fields should return the data you need.

    
04.09.2018 / 23:17