I have created angular application.in here, i want to inject some content using [innerHTML] property like below
export class AppComponent {
name = 'Angular';
public bar = 'bars';
foo = `<div>`+this.bar+`
</div>
<button type="button" onclick="alert('Hello world!')">Click Me!</button>
`;
}
I have used this in html file like below
<div [innerHTML]="foo"></div>
But I just simply return only div element. button control is not getting rendered.
I have created a stackb sample for your reference. please provide any idea how to do it
sample - https://stackblitz.com/edit/angular-ena2xj?file=src/app/app.component.ts
Reference - Angular HTML binding