title: Angular and ngDialog issue where data is not showing though dialog is shown correctly
body: <p>I am using Angular / Typescript with ng-Dialog. In this stage the ng-Dialog is showing the template correctly the way I want it. However, no data is shown. The scenario is this: I have a detail page that shows all the contacts list. The user clicks on a contact it calls the ContactController.selectRecord function and passes the index of the selected row. This function finds the specified contact and pops the dialog (up to this stage everything is working including the data). However, when the dialog is popped the values are not shown. The code is as following (code has been trimmed for brevity):</p>
  
  <pre><code>module CRM.Contacts {
   export class ContactController implements IShowMaintenanceDetails, ICrudController&lt;Contact&gt; {
      public newContact: Contact;
      public contacts: Contact[];
  
      static $inject = ["$http", "CRM.Contacts.ContactService", "CRM.Common.PopupService", "ngDialog"];
  
      constructor(private $http: ng.IHttpService, private contactService: ICrudService&lt;Contact&gt;,
                  private popupService: CRM.Common.IPopupService, private ngDialog: angular.dialog.IDialogService) {
      }
  
  
      selectRecord(index: number): void {
          this.newContact = this.contacts[index];
          this.ngDialog.openConfirm({
              template: "/js/controllers/_MaintainContact.Html",
              showClose: true,
              className: 'ngdialog-theme-default custom-width',
              controllerAs: "VM", //tried ContactController as VM
              data: this.newContact // tried json.Stringify(this.newContact)
              // controller:this // tried
              // controller:"ContactController" // tried
          });
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>the code in _MaintainContat.Html is (trimmed for brevity):</p>
  
  <pre><code>&lt;div id="contactAddNew" &gt;
  
  
      &lt;fieldset&gt;
  
          &lt;!-- Form Name --&gt;
          &lt;legend&gt;Contact&lt;/legend&gt;
  
          &lt;div class="row"&gt;
  
              &lt;div class="form-group col-md-6"&gt;
                  &lt;label class="col-md-4 control-label" for="id"&gt;ID:&lt;/label&gt;
                  &lt;div class="col-md-8"&gt;
                      &lt;input id="id" name="Id" ng-model="newContact.Id" type="text" placeholder="Id" ng-disabled="true" class="form-control input-md"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;!-- Text input--&gt;
              &lt;div class="form-group col-md-6 required"&gt;
                  &lt;label class="col-md-4 control-label" for="firstName"&gt;First Name:&lt;/label&gt;
                  &lt;div class="col-md-8"&gt;
                      &lt;input id="firstName" name="FirstName" required="" ng-model="VM.newContact.FirstName" type="text" placeholder="First Name" class="form-control input-md"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;!-- Text input--&gt;
              &lt;div class="form-group col-md-6 required"&gt;
                  &lt;label class="col-md-4 control-label" for="lastName"&gt;Last Name:&lt;/label&gt;
                  &lt;div class="col-md-8"&gt;
                      &lt;input id="lastName" name="LastName" required="" ng-model="VM.newContact.LastName" type="text" placeholder="Last Name" class="form-control input-md"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;!-- Save / Cancel / Delete buttons --&gt;
              &lt;div class="row"&gt;
                  &lt;div class="form-group col-md-offset-8"&gt;
                      &lt;label class="col-md-4 control-label" for="submit"&gt;&lt;/label&gt;
                      &lt;div class="col-md-8"&gt;
                          &lt;button id="submit" type="submit" title="Save new record" data-toggle="tooltip" data-placement="right" name="submit" ng-click="VM.saveRecord(VM.newContact)"
                                  class="btn btn-success" ng-disabled="addNewContactForm.$invalid"&gt;
                              &lt;span class="glyphicon glyphicon-floppy-disk"&gt;&lt;/span&gt;
                          &lt;/button&gt;
                          &lt;button title="Delete existing record" data-toggle="tooltip" data-placement="right" id="delete" ng-disabled="VM.newContact.RowIndex &lt; 0" class="btn btn-danger" ng-click="VM.deleteRecord(VM.newContact)"&gt;
                              &lt;span class="glyphicon glyphicon-trash"&gt;&lt;/span&gt;
                          &lt;/button&gt;
                          &lt;button title="Cancel adding new" data-toggle="tooltip" data-placement="right" id="cancel" name="cancel" class="btn btn-danger" ng-click="VM.hideAddNewDetails()"&gt;
                              &lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt;
                          &lt;/button&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
          &lt;/div&gt;
      &lt;/fieldset&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have played with many options of the ng-dialog i.e controller: this or controller: "ContactController", controllerAs: "ContactController as VM" or even controllerAs: "VM" but none of them works.</p>
  
  <p>Can anyone please let me know about the missing bit. Any comments will be appreciated.</p>
  
  <p>The next step would be to pass the updated data from _MaintainContat.Html back to ContactController.</p>
  
  <p>Any help will be appreciated.</p>
  
  <p>many thanks</p>