Aditya
Aditya

Reputation: 196

Interpolating variables within already interpolated strings in angular

I have the following arrangement to fetch helptexts from a single Coffeescript file.

Coffeescript:

help.ex: '{{example.variable}} identifies enterprise data centers'

HAML:

%example-directive(attr='{{help.ex}}')

Now the example.variable is accessible but it is not getting interpolated on the view. This I guess is happening because the string as a whole is getting interpolated and compile is not running on the variables within. How do I get around this?

Upvotes: 0

Views: 1038

Answers (1)

eladcon
eladcon

Reputation: 5825

You can use the $interpolate service:

var exp = $interpolate(attrs.attr) // interpolate your attriubte
var interpolated = exp(scope) // evaluate it with the scope variable

Check this plunker

Upvotes: 1

Related Questions