Urls to navigate in app


#1

Hi,

I’m writing a ‘newsreader’ application, the articles come from our webpage’s API. The text of the article can contains links which point to another articles. How can I use an URL in the article to nav between pages?

article.ts:

import {Deeplinks} from “ionic-native”;
@Page({
templateUrl: ‘build/pages/article/article.html’
})

export class ArticlePage {
article: any;
constructor(
    navParams: NavParams,
    private navCtrl: NavController,
    private platform: Platform
) {
    this.article = navParams.get('selectedEntry');
   }

checkLinks() {
    let that = this;
    this.platform.ready().then(() => {
        Deeplinks.route({
            '/article/:articleId': ArticlePage
        }).subscribe((match) => {
            console.log('Successfully routed', match);
        }, (nomatch) => {
            console.warn('nomatch ' + nomatch.$link);
        });
    });
}

ngAfterViewInit() {
     this.http.get(_url)
        .map(res => res.json())
        .subscribe(data => {
              this.article = ... 
              this.checkLinks();
         }
}

}

article.html:
<ion-content id="article" class="article" padding="true" [class]="style"> <h1 [innerHTML]="article.titlehtml"></h1> <div id="articleText" [innerHTML]="article.texthtml"></div> </ion-content>

I have added deeplinks plugin: cordova plugin add ionic-plugin-deeplinks --variable URL_SCHEME=myapp --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=myurl.com

And I tried these kind of URLs in the text:
myapp://article/1234
https://myurl.com/article/1234
https://article/1234

The text and the title show up on the page, but nothing happens if I click on the URLs.

Thanks,
Dave