It\'s possible evaluate template from string in a variable?. I need place the string in the component instead of the expression, e.g.
template: \"
In Angular double curly braces {{}} are used to evaluation an expression in a component's template. and not work on random strings or dynamically added DOM elements. So one way of doing this is to use typescript string interpolation using ${}. check the rest of code to understand
@Component({
selector: 'product-item',
template: `
`,
})
export class ProductItemComponent {
@Input() name: string;
@Input() price: number = 0;
@Input() template: string = `${ this.name } ${ this.price }}`;
}