[Solved] Get dropdown values using angular [closed]


You should use [(ngModel)]. For this, first you map your persons adding to properties “check” and “test”.

When you get the data, use “map” to add the properties

this.http.get(dataUrl).subscribe(response => {
  this.persons = response.data.map(x=>({...x,check:false,test:'test'}));
  this.dtTrigger.next();
});

Then you can change your .html, see how to disable you use [disabled]="!person.check?true:null"and the [(ngModel)]="person.check" and [(ngModel)]="person.test"

  <tr *ngFor="let person of persons">
    <td>
        <input [(ngModel)]="person.check" type="checkbox" 
               class="checkboxCls" name="id"></td>
    <td>{{ person.id }}</td>
    <td>
    <select [disabled]="!person.check?true:null" [(ngModel)]="person.test" 
            (change)="selected(person.test)">
      <option *ngFor="let prod of ProductHeader" [value]="prod.name" >{{prod.name}}</option>
    </select>
    </td>

See that you don’t need jQuery nor (click) in options and you can pass the value of the test in change function

Your forked stackblizt

0

solved Get dropdown values using angular [closed]