0

In my component.html, I have this select tag:

  <select class="inputGlobalStyle" [(ngModel)]="_user.profession" id="profession"
   [ngClass]="{'redInput': _user.professionError != null }" (change)="onSelectProfession($event)">
    <option [value]="undefined" *ngIf="_user.profession === undefined" selected>Choose a profession</option>
    <option *ngFor="let profession of professionsList" value="{{profession.activityCode}}">
      {{profession.activityWording}}
    </option>
  </select>

And there is the function in my component.ts

  onSelectProfession(event: Event) {
    let professionCode = event.target['options'][event.target['options'].selectedIndex].value;
    let activityWording = event.target['options'][event.target['options'].selectedIndex].text;
    console.log(professionCode);
    console.log(activityWording);

    this.subscriptionService.activityWording = activityWording;
  }

Is there a way to trigger the method "onSelectProfession($event)" to be able to fill the professionCode & activityWording variables automatically in update user case??

Thanks.

Z4n3tti
  • 115
  • 3
  • 13

0 Answers0