how to do the ng-bind-html of a directive?

1
<!-- ng-bind-html de uma diretiva customizado não funciona -->
<span ng-bind-html="customDirective"></span>


<!-- é renderizado -->
<choices-tab></choices-tab>

//Assim funciona:
$scope.customDirective = '<div class="alert alert-danger">teste</div>';

//Se eu fazer o ng-bind-html de uma diretive não funciona; não é renderizado nada
$scope.customDirective = '<choices-tab></choices-tab>';


angular.module('app')
.directive('choicesTab', function(){
    return {
        templateUrl: '../choices.html',
        link: function(){

        }
    }
});

ps. The policy works normally without ng-bind-html

    
asked by anonymous 08.08.2017 / 03:10

1 answer

0

I can not comment, so this text is not meant to be the answer.

What I have to say is that you have to use $ compile in the directive:

var app = angular.module('app', []);

app.directive('choicesTab', ['$compile', function($compile){
    return {
        templateUrl: '../choices.html',
        link: function(){

        }
    }
}]);

Then you can play Inception .

More references:

Using $ compile in Angular

Angular ng-bind-html and directive within it

    
08.08.2017 / 06:25