2

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.

JSBIN example

1 Answer 1

4

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.

1
  • Thanks man - I was not familiar with this service. It's exactly what i was looking for.
    – haki
    Commented Mar 4, 2014 at 8:59

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.