-2
 <option  *ngFor="let value of filterItem.values" [(value)]="value.code" [selected]="value.default_ind" required>{{value.displayName}}</option>

I have this option. Every of this records have default_ind: 1,2,3,4... I want to always select options with largest default_ind. Any suggestion how can i do that?

None
  • 7,955
  • 22
  • 81
  • 154

1 Answers1

0

Referring to this answer: https://stackoverflow.com/a/19308922/7741865 we could use

aMax = Math.max.apply.bind(Math.max, Math);

Then you can use this in template with any of your arrays:

<select [ngModel]="aMax(arr)">
  <option *ngFor="let val of arr">{{val}}</option>
</select>

DEMO: http://plnkr.co/edit/lz5z7eGLxOXzNdGrrd3Y?p=preview

AT82
  • 67,510
  • 23
  • 129
  • 159