1

All:

Right now, what I want to do is very basic:

Just use the default highlight feature of Solr, and show the result on page.

But strange thing is : I get the highlight string which like "asds < em>keyword</em>", but it was treated as a pure string, in the html: it is wrap in "", I wonder how can I make that treated as tag?

Thanks

UPDATE This update is replaced by UPDATE2

I have figured out myself in a dangerous unsuggested way:

    app.config(function($sceProvider) {
              // Completely disable SCE.  For demonstration purposes only!
              // Do not use in new projects.
              $sceProvider.enabled(false);
            });

//In this way, we can disable that so-called **sanitize**

UPDATE2 Thanks to MatsLindh

Refer to Angular JS shows HTML within the tag

Community
  • 1
  • 1
Kuan
  • 10,085
  • 18
  • 76
  • 168

1 Answers1

1

You don't want to disable sanitize completely. Just tell Angular that HTML is OK for that single expression.

This is currently done with:

<div ng-bind-html="expression"></div>
Community
  • 1
  • 1
MatsLindh
  • 37,884
  • 3
  • 33
  • 57
  • Thanks for reply. I use the same ng-bind-html in my page, but AngularJS gives me a error which says: "Error: error:unsafe Require a safe/trusted value Attempting to use an unsafe value in a safe context." – Kuan Dec 15 '14 at 17:16
  • You'll need to wrap it to tell AngularJS that the value is safe - see the comments in the linked post above, or [AngluarJS HTML within a Tag](http://stackoverflow.com/questions/21829275/angular-js-shows-html-within-the-tag) – MatsLindh Dec 15 '14 at 17:55
  • So the diff between $sce.trustAsHtml and $sce.enable(false) is one is limit that locally while the other make it global disabled? – Kuan Dec 15 '14 at 18:09