byCoder
byCoder

Reputation: 9184

AngularJS directive: template with scope value (ng-bind-html)

I have such directive:

...
template: function(element, attrs) {
    var htmlTemplate = '<div class="start-it" ng-if="isVisible">\
          <p ng-bind-html="\'{{customDynamicText}}\' | translate"></p>\
        </div>';
    return htmlTemplate;
},
...

(as you can see also i'm using translate plugin)

and there i have a problem: in scope this value is changing, but it doesn't change in directive(

when i'm using attrs-params (sure, if customDynamicText is a static string - all works) - but i have a dynamic variable customDynamicText

How can i use this dynamic variable in directive template with ng-bind-html.

Is it possible?

Upvotes: 9

Views: 592

Answers (1)

byCoder
byCoder

Reputation: 9184

Simply clever... I forgot to remove some quote-chars... So works:

...
<p ng-bind-html="' + attrs.customDynamicText + ' | translate"></p>\
...

Upvotes: 3

Related Questions