Is there an Angular 2 equivalent to Angular 1's $interpolate? I want to take a string and an object and be able to replace tokens in the string with values from the object.
example:
let myTemplateStr = "Hello {{user.name}}, you are {{user.age.years}} years old"
//use the Angular2 equivalent of interpolate
let myTemplateCompiled = Angular2.Interpolate(myTemplateStr, {
user: {
name: "bob",
age: {
years: 10
}
}})
//myTemplateCompiled ends up becoming "Hello bob, you are 10 years old"
I could write something that would do this for me but I would prefer to use a built in angular way if possible.
EDIT:
I should have mentioned that the interpolation needs to be able to to happen with string variable. I know typescript/es6 have backtick interpolation for literal strings, but I need to interpolate a string templated stored in a variable. Perhaps there is a way to use typescript built in interpolation for a string template in a variable that I am unaware of?