Header Ads

Convert Wordpress Website to ionic app

Convert Wordpress Website to ionic app



Ionic is a mobile app development framework and it was a hybrid app framework, basically, develop the new in android, iPhone, windows. also, it was an opensource framework.

From the ionic, converting the WordPress website to the ionic app and gives more user-friendly apps.  So first all we have to choose the website name, which has to convert as an ionic app.



import { Component } from '@angular/core';
@Component({
  selector: 'page-feedlist',
  templateUrl: 'feedlist.html',
})
export class Feedlist { 
public selectedFeed = {tilte: '', url: 'www.example.com/feed'};
constructor() {
    this.feedProvider.getArticlesForUrl(this.selectedFeed.url).subscribe(res =>
    {
      this.articles = res;
      console.log("article",this.articles);
    });
 }
}

From this page, called the services and it will convert the XML format to json format. so it will be used in our app to design user experiences

   public getArticlesForUrl(feedUrl: string):Observable<any> {
       var url = 'https://api.rss2json.com/v1/api.json?rss_url='+encodeURIComponent(feedUrl);
       let headers = new Headers();
       headers.append('Content-Type', 'application/x-www-form-urlencoded');
       let options = new RequestOptions({ headers: headers });
       let articles = [];
       //observable
       return this.http.get(feedUrl,options)
       .map(res => JSON.parse(xml2json(res.text(),'  ')))
       .map((res) => {
         var res2=res.rss.channel;
      })
      .catch(this.handleError)
     
  }
  handleError(error) {
        console.error("error",error);
        return Observable.throw(error.json().error || 'Server error');
    } 

Post a Comment

0 Comments