• 방법 1
1
2
<div [innerHTML]="theHtmlString">
</div>
  • 방법 2

    id 부여

1
<div #scheduleContents></div>

컴포넌트 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
import { Component, ViewChild, ElementRef } from '@angular/core';

@Component({
templateUrl: "some html file"
})
export class MainPageComponent {

@ViewChild('dataContainer') dataContainer: ElementRef;

loadData(data) { // 데이터를 불러오는 로직 추가
this.dataContainer.nativeElement.innerHTML = data;
}
}

Reference

http://stackoverflow.com/questions/31548311/angular-2-html-binding

Comment and share

Author's picture

Junho Nam

enjoy while living


full stack web developer


Seoul, Korea