Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind html into Angular 2.0 [duplicate]

In angular 1 binding works like ng-bind-html="htmlValue"

How to bind html in Angular 2.0

like image 959
navin saini Avatar asked Jan 07 '16 12:01

navin saini


1 Answers

I think that you could use the innerHtml attribute and bind something on it:

<span [innerHtml]="someHtmlContent"></span>

Here is a sample:

@Component({
  selector: 'first-app',
  template: `
    <span [innerHtml]="value"></span>
  `
})
export class AppComponent {
  constructor(private http:Http) {
    this.value = '<strong>test</strong>';
  }
}
like image 175
Thierry Templier Avatar answered Sep 21 '22 21:09

Thierry Templier