AngularJS directive in ng-bind-html -


In the application I am working, a service provides an app with a JSN, which includes HTML I Output in the template like this:

  & lt; Div ng-bind-html = "renderHtml (widget.article.body)" & gt; & Lt; / Div & gt;  This HTML can have custom instructions, such as an inline-chart:  
  directiveModule.directive ('inlinechart', function () {return} Restrict: 'A', scope: {inline-widget: '= elem'}, template: '& lt; p ng-bind = "inline-widget.blah">  ;});  

If I normally use the instructions in a template, then everything works fine, but it seems that NG-Bing-HTML is used when rendered HTML function it happens.

How any suggestion can be obtained is greatly appreciated!

You should use the NGSNeted module and $ sce service. It should look something like this:

  // found on Angular website from Connular-Sanitizies.Jesus below and // should also be included in the web app. Angular Module ('myApp', [ngSanitize ']); Angular.module ('myApp'). Controller ('MyCtrl', function ($ radius, $ sce) {// ... other controller code $ scope.renderHtml = function (html) {return $ sce.trustAsHtml (html);};});  

In short, the $ sce service will mark the html as a trust. You can get the documentation

Edit : I know that I have not answered this question. It seems that you are asking about the binding variable for the instructions which is provided within your direction? To properly compile elements, you have to use the $ compile service and change your logic in small amounts. First, the template:

  & lt; P class = "place-directive-here" & gt; & Lt; / P & gt;  

Instructions:

  Angular. Module ('myApp'). Directive ('myDirective', function ($ compilation) {return {scope: {InlineWidget: '='}, Template: '& lt; p class = "place-directive-here">  ; Link: function (scope, amm, ethers) {var placement = elem.find 'Place-directive-here'), radius. $ Watch ('inlineWidget', function) {if widget!} {Return;} // compile html against the scope, this dom / / current scope var newElement = $ compilation (widget.blah) (scope) Place it in the // placement placement.html (NewAlment);});}};});  

You can find the compiled documentation. Hope this is a more comprehensive answer for you.

Edit 2: For clarification, the instructions should appear on this page:

  & lt; Div my-directive inline-widget = "some inlinewidget" & gt; & Lt; / Div & gt;   

Location-director-here class is in your & lt; P & gt; There is just one handle to search for and search inside the tag. However, if the angle is not related to html which is provided inside my-directive So the first solution I have provided is to do well and work should be my-directive :

  template: '& lt; P ng-bind-html = "renderHtml (InlineWidt. Blah)" & gt; & Lt; / P & gt;  

Comments