1
 @Component({
        selector: 'my-app',
        template: `{{name}}`
    })
    export class AppComponent {
        data: string = "data"
        name:string
        constructor() {
            this.name = "<input [(ngModel)]='data' />"
        }
}

I want to show textbox and binding data variable

2 Answers2

1

This is not supported.

You can create components at runtime using the compiler class (there are related answers and questions here).

Besides that Angular doesn't process bindings or component or directive selectors that are added to the DOM, it does it only with markup added to a components template statically.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
0

https://stackoverflow.com/a/34424375/2160958

The correct syntax is now the following:

<div [innerHTML]="theHtmlString"> </div> Working in "2.0.0"

Community
  • 1
  • 1
vardius
  • 6,326
  • 8
  • 52
  • 97
  • This will apply string as html, but will not work with angular directive and syntax. there is no other way then change your code to at least use this html binding. – vardius Oct 13 '16 at 08:23