javascript - AngularJS: ngBindHtml that also contains child bindings? -


this question has answer here:

angularjs v1.3.14: currently, i'm using 'ngsanitize' module in angular app "ng-bind-html" bind html output of area on page. works , doesn't require older $sce 'trust html' stuff.

but, i'd embed child bindings within html.

so... works...

angular.module('myapp', ['ngsanitize'...)     .controller('somectrl', ['$scope', function($scope) {         $scope.myhtml = '<p>hello world</p>'; }]); ... <div ng-app="myapp" ng-controller="somectrl" ng-bind-html="myhtml"></div> 

something doesn't...

angular.module('myapp', ['ngsanitize'...)     .controller('somectrl', ['$scope', function($scope) {         $scope.mycontent = 'hello world';         $scope.myhtml = '<p>{{mycontent}}</p>'; }]); ... <div ng-app="myapp" ng-controller="somectrl" ng-bind-html="myhtml"></div> 

thoughts?

a simple directive it:

<div bindy="myhtml"></div> 
.directive('bindy', function($compile) {   return {     link: function($scope, $element, $attrs) {       var html = $scope.$eval($attrs.bindy);       $element.html(html);       $compile($element.contents())($scope);     }   }; }); 

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

amazon web services - Installing MobileFirst 7.0 server on AWS -

Non Unique Username with ASP.Net Identity 2.0 -