Wednesday, 19 May 2021

dynamic form binding

 <form (ngSubmit)="onsubmit()">

<div class="col-sm-6">
                            <div class="form-group" *ngFor="let i of textarray">
                                 <label for="" class="block">{{i.label}} </label>
                              <input name="name" type="text" class="form-control"
                                 [(ngModel)]="i.label">
                            </div>
                            
                          <button class="btn btn-primary">Submit</button>

</div>
                          </form>


   this.entrustservice.getcustomFields().subscribe((responseany) => {

       this.auditLogs = response;
        console.logthis.auditLogs)
//ignore this lines
        function filter(response, query) {
          return Object.values(Object.keys(response)
            .filter(key => new RegExp('^' + query, 'g').test(key))
            .map((key) => response[key]));
        }
        this.datearray=filter(response,'date');
          this.datearray = this.datearray.filter(obj => obj.enabled === true);
        this.textarray=filter(response,'text');
          this.textarray = this.textarray.filter(obj => obj.enabled === true);
        this.dropdownarray=filter(response,'dropdown');
          this.dropdownarray = this.dropdownarray.filter(obj => obj.enabled === true);
        console.log(filter(response, 'date'));
        console.log(filter(response, 'text'));
        console.log(filter(response, 'dropdown'));
            //  this.x=date; ignoe these above lines
      this.dataaarays.push(this.auditLogs);
     console.logthis.auditLogs);
//saving response to array dynamic form
//insead of response bind class save data
      });

  }

onsubmit(){
  console.log(this.dataaarays)
}

No comments:

Post a Comment

7 Common mistakes in Dot Net — You can avoid

  There are many common mistakes made during .NET (ASP.NET, .NET Core) development, which affect performance, security, and code… Code Crack...