1
Ionic2 앱을 만들고 있습니다. e.x (http : www.example.com/test-view.html)에 외부 templateUrl을로드하려는 구성 요소가 있습니다.ionic2에서 외부 HTML 페이지를로드하는 방법
어떻게 HTML을 @Component의 templateUrl 변수에로드 할 수 있습니까?
여기까지 제가 지금까지 가지고 있습니다.
import { Component, DynamicComponentLoader, ViewContainerRef,
ViewChild } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { Http, Headers, RequestOptions } from '@angular/http';
@Component({
//templateUrl: 'build/pages/hello-ionic/hello-ionic.html'
template: `<div [innerHTML]="myVal"></div>`,
selector: 'HelloIonicPage'
})
export class HelloIonicPage {
myVal: any;
viewLink: any;
viewHtml: any;
constructor(private http: Http) {
let headers = new Headers({ 'Content-Type': 'text/html' });
let options = new RequestOptions({ headers: headers });
this.viewHtml = this.http.get('http://example.net//test-view1.html');
this.myVal = this.viewLink
console.log(this.myVal);
}
}
내가 이렇게하면 XSS 오류가 발생합니다 : XMLHttpRequest는 http : //website/test-view1.html을로드 할 수 없습니다. 'Access-Control- Allow-Origin '헤더가 요청 된 리소스에 존재합니다.'http : // localhost : 8100 '의 출처가 액세스 할 수 없으므로 – ShadowVariable
프록시를 설정해야한다는 것을 알았습니다! 감사합니다. D – ShadowVariable
@ShadowVariable, can 프록시 설정 방법을 보여 주시겠습니까? –