I have a select:
  <select id="position">
    <option *ngFor='#contactType of contactTypes' [attr.value]='contactType.contactTypeId'>
      {{contactType.description}}
    </option>
  </select>
I would like to have a selected option on condition: 'contactType.contactTypeId == number' without using ngModel
I guess this is what you want:
 <select id="position">
    <option *ngFor='#contactType of contactTypes'
      [attr.value]='contactType.contactTypeId' 
      [attr.selected]="contactType.contactTypeId == number ? true : null">
      {{contactType.description}}
    </option>
  </select>
To get the selected attribute removed you need to return null (false results in selected="false").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With