title: How to Update data in Modal using Angular2?
body: <p>This is My Angular2 part.Here <code>Updateuser</code> function for update data in database </p>
  
  <pre><code>export class UserprofileComponent 
      {
            getdata : string;     
            public data;     
             Username : any ;   
             Firstname :any;             
      updateuser(){
           let re = /[?&amp;]([^=#&amp;]+)=([^&amp;#]*)/g;
           let match;
           let isMatch = true;
           let matches = {};
               while (isMatch) 
               {
                     match = re.exec(window.location.href);
                        if (match !== null)
                        {
                            matches[decodeURIComponent(match[1])] = decodeURIComponent(match[2]);
                                if (match.index === re.lastIndex)
                                 {
                                      re.lastIndex++;
                                 }
                          }
                          else {
                                     isMatch = false;
                               }
                    }
               console.log(matches);
               var headers= new Headers({'Content-Type' : 'application/x-www-form-urlencoded '}); 
  
          var body = JSON.stringify({     
             username1 : this.user.Username,
             firstname1 : this.user.Firstname,               
       })            
        this.http.post('../widgets/Update.php?ID='+matches['ID'],body, {
        headers:headers; })
         .map(res =&gt; res.json())
         .map(res =&gt; {
               if(res.success)
               {
                  this.m=res.Message;
               }
               else{
                   this.m="wrong";
               }
          })
            .subscribe(
              data =&gt;this.getdata = JSON.stringify(data),
              err =&gt; console.error(err),
              () =&gt; console.log('done'));
          }
      }
  </code></pre>
  
  <p>This is My html part:</p>
  
  <pre><code> &lt;ngl-modal header=" Edit Profile" [(open)]="opened" [size]="size"&gt;
         &lt;div body&gt;           
      &lt;div class="form-horizontal" style="margin:auto;" id="editForm" *ngFor="#user of getdata"&gt;
          &lt;div class="form-group"&gt;
              &lt;label class="col-md-3 control-label"&gt;Username:&lt;/label&gt;
              &lt;div class="col-md-8"&gt;
                  &lt;input type="text" class="form-control" id="cname" [(ngModel)]="user.Username" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;label class="col-md-3 control-label"&gt;Firstname:&lt;/label&gt;
              &lt;div class="col-md-8"&gt;
                  &lt;input type="text" class="form-control" id="ads" [(ngModel)]="user.Firstname"/&gt;
              &lt;/div&gt;    
         &lt;/div&gt;
          &lt;span&gt;{{m}}&lt;/span&gt;
        &lt;button class="slds-button slds-button--neutral" (click)="cancel()"&gt;Cancel&lt;/button&gt;
        &lt;button class="slds-button slds-button--neutral slds-button--brand" (click)="updateuser()"&gt;Save&lt;/button&gt;
      &lt;/ngl-modal&gt;
  </code></pre>
  
  <p>Here I'd use modal for displaying the data which is display by ngFor.But I want to update this display data so how to do it?Because data is display by ngModel and when I'm taking the whole <code>ngModel</code> value for example if <code>[(ngModel)]="user.name"</code> then it showing the error that user is not define so what to do in this case??</p>