Reputation: 9759
I want to evaluate a string in the form of "my name is {{name}}"
where name
is present in the current scope (same way angular does for html content).
This should be simple but i haven't managed to achieve that with eval
nor compile
.
Upvotes: 2
Views: 623
Reputation: 74146
Use the $interpolate
service, like:
console.log("using $interpolate: " + $interpolate("'" + s + "'")(scope));
Compiles a string with markup into an interpolation function. This service is used by the HTML $compile service for data binding.
Upvotes: 4