If you have an array:
1 |
someArray: Ember.A([3,2,4,1]) |
You can get the maximum value with a computed property
1 |
maxNumber: Ember.computed.max('someArray') |
The maxNumber property will always have the maximum value in the array and will auto re-compute and update any bindings automatically.
Here is some sample code:
https://ember-twiddle.com/43939812f6c9729845bff7072619c361?openFiles=controllers.application.js%2C
Bonus
You can get the minimum with
1 |
Ember.computed.min |
See more at http://emberjs.com/api/classes/Ember.computed.html
Also published on Medium.