Use a template literal to interpolate variables in a string in TypeScript, e.g. hello ${myVariable} . Template literals are delimited with backticks and allow us to embed variables and expressions using the dollar sign and curly braces ${expression} syntax.
String interpolation is a great programming language feature that allows injecting variables, function calls, arithmetic expressions directly into a string.
String Interpolation is a one-way databinding technique which is used to output the data from a TypeScript code to HTML template (view). It uses the template expression in double curly braces to display the data from the component to the view.
In JavaScript you can use template literals:
let value = 100;
console.log(`The size is ${ value }`);
Just use special `
var lyrics = 'Never gonna give you up';
var html = `<div>${lyrics}</div>`;
You can see more examples here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With