Hi,
I’m developing a app to view different articles . In this i needed to change the article by swipe. Each article has different urls to be called.
My html:
<ion-content padding (swipe)="swipeEvent($event)">
<div *ngIf="article">
<h2 [innerHTML]="article.title"></h2>
<strong [innerHTML]="article.teaser"></strong>
<span [innerHTML]="article.description" [class.larger]="larger"></span>
</div>
</ion-content>
my ts function:
getArticle(id){
this.http.get(this.constants.api_article + id).map(res => res.json()).subscribe(article => {
this.article = article.output;
});
}
swipeEvent(e) {
console.log(e);
var swipe :any;
this.storage.get("ArticleId").then((value) => {
this.ArticleID = value;
swipe = this.ArticleID.indexOf(this.article_inner.article_id);
if(e.direction == 2){
swipe = swipe +1;
this.getArticle(this.ArticleID[swipe]);
}
else if(e.direction == 4){
swipe = swipe -1;
this.getArticle(this.ArticleID[swipe]);
}
})
}
If a click a article and swipe left it will show the next article,and it we again swipe left it won’t. Same if I swipe rigth. The swiping will effect only for the clicked article and not the viewing article.
Any suggestion is appreciable.
Thanks,