-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
  • 8,817
  • 26
  • 96
  • 171

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
  • 71,416
  • 24
  • 140
  • 167