How to count json data item ionic2


#1

i find a new problem, i would like to count @NAME to set array FACET[] for show @KEY

myjson

 "    RESULT":{
              "FACET":[
                { "@NAME" : "creator", 
                  "@COUNT" : "20",
                  "FACET_VALUES":[
                    {
                      "@KEY":"Book Company1",
                      "@VALUE":"13"},
                    {
                      "@KEY":"Book Company1์",
                      "@VALUE":"10"}],
                { "@NAME" : "lang", 
                  "@COUNT" : "70",
                  "FACET_VALUES":[
                    {
                      "@KEY":"tha",
                      "@VALUE":"33"},
                    {
                      "@KEY":"eng",
                      "@VALUE":"42"}
                   ],
                { "@NAME" : "bnb", 
                  "@COUNT" : "64",
                  "FACET_VALUES":[
                    {
                         .
                         .
                         .

              ] 

.

  optionsFn(): void {
            this.http.get("my_url")
                        .subscribe(data =>{
                                 this.date=data.json().RESULT.FACET; //get @NAME
                        },error=>{
err => console.error(err),
                           () => console.log('getRepos completed')
            );
        console.log(this.date);

            console.log(this.date);
            this.goToapply()
      }

      goToapply(){

       this.http.get("my_url")
                        .subscribe(data =>{
                                 this.foundRepos=data.json().RESULT.FACET[0,1,2,3.4......].FACET_VALUES; ///get @KEY
                        },error=>{
                            console.log(error);
                        } );

      }

.

<ion-label>Filterr</ion-label>
              <ion-select [(ngModel)]="refine" (ionChange)="optionsFn();">
                <ion-option value="..." *ngFor="let item of date">{{item["@NAME"]}},({{item["@COUNT"]}})</ion-option>
              </ion-select>
    <ion-list>          
              <ion-item *ngFor="let item of foundRepos" (click)="itemClicked($event,item)">
                <h3> {{ item[@KEY"] }}</h3>
              </ion-item>
            </ion-list>

this value="..." i want to keep it to string for to use, but i have know idea.

example : count @NAME = 3 (creator,lang,bnb) ,and get value="..." = 0,1,2 (0==creator ,1==lang ,2==bnb) when i select lang i get 1 ,i use this to FACET[1].FACET_VALUES ,so that i get @KEY