Pour charger un fichier avec ionic cordova :
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';
@IonicPage()
@Component({
selector:'page-phase',
templateUrl:'phase.html',
})
export class PhasePage {
publiclien:string="";
publichtmlfile:string="";
constructor(publicnavCtrl:NavController, publicnavParams:NavParams, publichttp:HttpClient) {
this.lien=navParams.get('lien');
this.http.get('/assets/data/'+this.lien+'.xml',
{
headers:newHttpHeaders()
.set('Content-Type', 'text/xml')
.append('Access-Control-Allow-Methods', 'GET')
.append('Access-Control-Allow-Origin', '*')
.append('Access-Control-Allow-Headers', "Access-Control-Allow-Headers, Access-Control-Allow-Origin, Access-Control-Request-Method"),
responseType:'text'
})
.subscribe((data)=>
{
this.htmlfile=data;
});
}
ionViewDidLoad() {
console.log('ionViewDidLoad PhasePage');
}
}