Localstorage Item on Top of List

HI All,
I am using ionic 2 Ngfor loop and getting one list to show . Now i want to localstorage item which is based on item id on top . Like i selected no 5 previously now when i go to that number it should be shown on top of the list . How could it is possible to show that data from the list.

my code is as following

 <ion-item  *ngFor="let company of companyDataClone; let i = index" (click)="getnext($event,company?.id)">
      <p>{{company?.id}} -- {{company?.text}}</p>
      <ion-icon *ngIf="(i==0 &&selectedCompany && company?.id!=selectedCompany && !showApply && !localstore)" name="checkmark" item-right></ion-icon>
      <ion-icon *ngIf="((company?.id==selectedCompany) && (showApply || localstore))" name="checkmark" item-right></ion-icon>

Your template expressions are way too complex. You should only be checking one property and you don’t need any of those ?. Elvis operators. Shift all the work to the controller, including what you are asking about. Move the items around in the backing array into the order you desire, instead of making the template worry about it.

I did some changes now i want to order by some data . I want to put status true on top which is coming from API . now my array of obect is smoething like

var abc = [{'status' : false , 'name' : 'one', 'value' : 32} , {'status' : false , 'name' : 'two', 'value' : 93}, {'status' : true , 'name' : 'three', 'value' :333}]

now i want to show status true on top . need help for it.

you can iterate over your array an sort it as you want. see here for basics https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

If you have more then once to do with arrays, maybe some helpers like _underscore or lodash are helpful.

By the way: use let instead of var in typescript as long you do not need it explicit.

Best regards, anna-liebt