2017-01-29 9 views
0

これはバグか自分のコードの問題か分かりませんか?Angular2 Httpがhtmlで間違ったデータを表示する

現在、私はHTTPフィードでRSSフィードを取得するためにforEachを使用しようとしていますが、それは大文字小文字ではないはずの1つのRSSフィードからのデータのみを表示します。しかし、コンソールログでは正しい動作をエミュレートしています。

私は数日間解決しようとしています。

私のHTMLコード

<div *ngFor="let category of favouritecategories | async"><h3 class="header" [id]="category.name">{{category.name}}</h3> 

<ion-item-sliding *ngFor="let item of xmlItemsApac; let i=index" #slidingItem> 

    <ion-item *ngIf="i<articlecount" text-wrap> 
    <div class (click)="openbrowser(item.link)"><h2>{{item.title}}</h2> 
    <p class="block-with-text"> {{item.description}}</p></div> 
    </ion-item> 
    <ion-item-options side="right"> 
    <button ion-button color="custom" (click)="bookmark(item.title,item.description,item.link,slidingItem)"><ion-icon name="bookmark"></ion-icon>Bookmark</button> 
    </ion-item-options> 

    <ion-item *ngIf="i>articlecount" [hidden]="!showMoreAmericas" text-wrap> 
    <div class (click)="openbrowser(item.link)"><h2>{{item.title}}</h2> 
    <p class="block-with-text"> {{item.description}}</p></div> 
    </ion-item> 
    <ion-item-options side="right"> 
    <button ion-button color="custom" (click)="bookmark(item.title,item.description,item.link,slidingItem)"><ion-icon name="bookmark"></ion-icon>Bookmark</button> 
    </ion-item-options> 

</ion-item-sliding> 

<button ion-item (click)="toggleMoreArticle()" text-center detail-none large> 
    <h4 class="showMoreText"><ion-icon name="arrow-down" *ngIf="!arrows"></ion-icon> 
    <ion-icon name="arrow-up" *ngIf="arrow"></ion-icon> {{buttonText}}</h4> 
</button><br/> 

</div> 

私の活字体

this.af.database.list(`/users/${userid}/favourites`) 
    .subscribe(snapshots => { 
    snapshots.forEach(snapshot => { 
     this.Apac = this.http.get(snapshot.regions[0].rss) 
     this.Apac.map(res => res.text()) 
      .subscribe((data) => { 
      this.parseXML(data) 
       .then((data) => { 
       this.xmlItemsApac = data; 
       console.log(this.xmlItemsApac) 
       }); 
      }); 
    }); 
    }); 

答えて

0

あなたはthis.xmlItemsApac。あなたのあなたのRSSエントリを交換する空の配列にそれを初期化する必要があります。 this.xmlItemsApac=[]

と値

this.af.database.list(`/users/${userid}/favourites`) 
    .subscribe(snapshots => { 
    snapshots.forEach(snapshot => { 
     this.Apac = this.http.get(snapshot.regions[0].rss) 
     this.Apac.map(res => res.text()) 
      .subscribe((data) => { 
      this.parseXML(data) 
       .then((data) => { 
       this.xmlItemsApac.push(data); 
       console.log(this.xmlItemsApac) 
       }); 
      }); 
    }); 
    }); 
+0

を押し@surajこんにちは、私も私のhtmlのために行う必要があるが、それは 'イオン-項目スライドが内側にあるべき –

+0

を働いているように見えるdoes notのものがありますイオンリスト ' –

+0

はい、それは既にイオンリスト内にありますが、私のビューには何も表示されず、コンソールログには3つの配列 –

関連する問題