angularjs - Logging form field value when close modal in Angular -


i have trying console.log form field when user closes modal, unsure how this.

when use code below, input in form field not reflected. ideas?

javascript:

.controller('contactformctrl',  function($modal) {   var contactform = this;   contactform.agreement = agreement;   contactform.contact.signature = '';  return;  function agreement() {   $modal.open({      templateurl: 'views/agreement.html'   })     .result.then(     function () {       var agreement=contactform.contact.signature;       console.log(agreement);       (contactform.value1 = true);      },     function () {       contactform.value1 = false;     }   ); } }); 

html:

<form name="paymentform">   <div class="form-group>     <label class="control-label" for="signature">signature</label>     <input type="text" id="signature" name="signature" ng-model="contactform.contact.signature" aria-describedby="signaturewarning" placeholder="signature (e.g., /john doe/)" class="form-control" ng-minlength=1 ng-model-options="{ updateon: 'default blur', debounce: {'default': 500, 'blur': 0} }" required /> </div>  <button ng-click="$dismiss()" class="btn btn-warning">cancel</button> <button ng-click="$close()" class="btn btn-primary" ng-disabled="paymentform.$invalid">i agree</button> 

you'd have easier time handling form data inside modal controller extracting it. there's not good/recommended way access scope outside $modal, since there few scope layers modal itself.

it better have save method or something:

$scope.save = function() {   // post data somewhere, save service, whatever   $modalinstance.$close(); // or whatever api }  <button ng-click="save()" class="btn btn-primary" ng-disabled="paymentform.$invalid">i agree</button> 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -