angularjs - Appending ngBindHtml function using .attr in link function not working -


a attempting attach ngbindhtml directive in application within link function of directive. module in directive located injects ngsanitize such:

 angular.module('ui.bootstrap.contextmenu', ['ngsanitize'])     .directive('contextmenu', cm); 

where cm directive function. link function looks like:

var link = function ($scope, element, attrs) {         element.on('contextmenu', function (event) {             event.stoppropagation();             $scope.$apply(function () {                 event.preventdefault();                 var options = $scope.$eval(attrs.contextmenu);                 var model = $scope.$eval(attrs.model);                 if (options instanceof array) {                     if (options.length === 0) {                         return;                     }                     rendercontextmenu($scope, event, options, model);                 } else {                     throw '"' + attrs.contextmenu + '" not array';                 }             });         });     }; 

where rendercontextmenu sketches out html attached body of page. within function have following lines of code:

$div.attr('ng-bind-html', text); $a.append($div); 

which should produce looks like:

<a><div ng-bind-html="the text"></div></a> 

and does. problem text not displayed. have thoughts on this?

i think "angular-y" way of doing put html code context menu you're hoping bind directly template, , hide/show appropriate: show if valid contextmenu event occurs , has options.length > 0.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -