import Route from
'@ember/routing/route'
;
import { sortBy } from
'@ember/array'
;
export
default
class RichestPeopleRoute extends Route {
richestPeople = [
{
'name'
:
'mukesh ambani'
,
'net-worth'
: 90.7 },
{
'name'
:
'jeff Bezos'
,
'net-worth'
: 148.1 },
{
'name'
:
'Warren Buffet'
,
'net-worth'
: 99.3 },
{
'name'
:
'Bill gates'
,
'net-worth'
: 104.7 },
{
'name'
:
'elon Musk'
,
'net-worth'
: 253.4 },
{
'name'
:
'gautam adani and family'
,
'net-worth'
: 115.8
},
{
'name'
:
'Larry Page'
,
'net-worth'
: 93.4 },
{
'name'
:
'larryEllison'
,
'net-worth'
: 103.3 },
{
'name'
:
'sergeyBrin'
,
'net-worth'
: 89.9 },
{
'name'
:
'bernard Arnault and family'
,
'net-worth'
: 157.1
},
];
firstPerson;
lastPerson;
idx = 5;
randomPerson;
num;
model() {
this
.richestPeople =
this
.richestPeople.sortBy(
'net-worth'
);
this
.randomPerson =
this
.richestPeople[
this
.idx - 1];
return
this
.richestPeople;
}
setupController(controller, model) {
this
._super(controller, model);
controller.set(
'idx'
,
this
.idx);
controller.set(
'firstPerson'
,
this
.richestPeople.firstObject);
controller.set(
'lastPerson'
,
this
.richestPeople.lastObject);
controller.set(
'randomPerson'
,
this
.randomPerson);
controller.set(
'richestPeople'
,
this
.richestPeople);
controller.set(
'num'
,
this
.richestPeople.length);
}
}