Search code examples
javascripthtmlangularjsinterpolationstring-interpolation

AngularJs: How to interpolate an interpolated string?


I'm trying to Interpolate a string coming from a database which looks like this "Users({{users_count || 0}})", and when I interpolate it using {{}} or ng-bind it doesn't get interpolated, because in the HTML I write {{data.usersCount}} and the page interpolates the data as text not as js, (what I intended the page to render is Users(8), and what gets rendered is Users({{users_count || 0}})). So my question is how to interpolate the string that was interpolated from the usersCount variable?


Solution

  • One way is to use $interpolate, as in

    $interpolate("Users({{users_count || 0}})")($scope)