I have a string like {name} is my name. Greeting {sender}
is there some module in angualar 2.0, so that i can do something like string.format()
as we do in C#?
I know this can be done using vanila js custom method, but i want to know is there any module inside angular 2 to handle this. They use interpolation in template binding so how to do that with a normal string
Check ES6 Template literals. It enables multi-line strings and string interpolation.
Example:
var name = 'John',
age = 19;
console.log(`${name} is my name. I'm ${age}.`);
// => John is my name. I'm 19.
TypeScript from version 1.4 supports ES6 Template literals and can compile them down to ES3/ES5 expressions.
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