Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I currently have a data feed in my Angular setup which returns certain data as HTML. For example, it returns:

"It’s".

In the template, I can use ng-bind-html so that it displays as "It's", but how do I do this within the controller? I need to do this as I am setting the page title dynamically, but it is displaying the HTML characters above, rather than formatting it correctly.

E.g. using:

$scope.name = data.word (but formats HTML?)
share|improve this question
    
This should get you started docs.angularjs.org/api/ng/service/$sce – Claies yesterday

1 Answer 1

inject $sce and use the following code

$scope.name = $sce.trustAsHtml(data.word;

share|improve this answer
    
Thanks for your input. I've added this to the controller, but it is still displaying the HTML codes in the page title. Am i missing something? – Matt Price yesterday
    
Have you inject Sanitize in your controller ? – Kais 20 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.