0

Say I have a service that returns me an HTML like

Welcome {{UserName}}
now even when UserName is defined in current scope, that angular expression doesn't get decoded means for me the result should be like
Welcome Dummy User but the achieved result is like Welcome {{UserName}}

3
  • I think you are going to have to supply more context to the question. Maybe some more illustrative HTML and JavaScript? Ideally, a small jsFiddle. Commented Nov 9, 2014 at 23:30
  • Would also like to mention that I have tried $compile in both ways i.e. $compile(containerElem, $scope) and $compile(containerElem)($scope) and that doesn't work as well Commented Nov 9, 2014 at 23:30
  • @Kolban here you have a sample code [link]plnkr.co/edit/B1BsXozy12bHJqgvbUaC?p=preview Commented Nov 9, 2014 at 23:45

1 Answer 1

1

I've modified your code.

Here is the line of code which is going to do the magic (compile a string with markup into an interpolation function and then execute is against the scope.)

$element.parent().append($interpolate(dummyService.htmlStr)($scope));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.