You can simply use [innerHTML]
directive to accomplish it.
http://plnkr.co/edit/6x04QSKhqbDwPvdsLSL9?p=preview
import {Component, Pipe} from '@angular/core'
@Component({
selector: 'my-app',
template: `
Hello my name is <span [innerHTML]="myName"></span>
`,
})
export class AppComponent {
myName='<strong>Pardeep</strong>';
}
Update:
I checked it doesn't work this way after RC.1 release.
Let's say to make it work with RC.4 you can use DomSanitizationService
as shown below,
@Component({
selector: 'my-app',
template: `
<div [innerHTML]="myCheckbox"></div>
`,
})
export class AppComponent {
dangerousUrl='<input type="checkbox">';
constructor(sanitizer: DomSanitizationService) {
this.myCheckbox= sanitizer.bypassSecurityTrustHtml(this.dangerousUrl);
}
}
http://plnkr.co/edit/Yexm1Mf8B3FRhNch3EMz?p=preview
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…