0

I got this directive which renders a list of objects. this objects got it's own function, i wanna bind it to a button. So i run over my items.In my objects value, i got a prop called Action which value is a function. i then try to add it to the html string, then i say it should be trusted as html. like shown below

angular.forEach(data.Items, function (value, key) {
      var buttonsCode = "";
      buttonsCode += '<div class="btn btn-sm" ng-click="' + value.Action + '">Test</div>';
      value["buttons"] = $sce.trustAsHtml(buttonsCode);
});

but when i try to run it, it looks like this

<div class="btn btn-sm" ng-click="function () {
    alert("test of funtion"); }">Test</div>

Anyone know how i can do this?

4

0 回答 0