ng-click won't work with ng-bind-html

前端 未结 2 1248
粉色の甜心
粉色の甜心 2021-01-21 06:54

I have html template like this:

$scope.template = \'

        
相关标签:
2条回答
  • 2021-01-21 07:06

    You could try ng-include and put your template in to a static file instead.

    Putting HTML content in scope variables kind of goes against some angular philosophy guidelines, I believe.

    If you were to later change the template, would you want it to rebind itself and be processed again?

    0 讨论(0)
  • 2021-01-21 07:24

    Perhaps you need to compile the template inside the controller?

    angular.controller('ABCDCtrl', function($scope, $compile){
        var templateHTML = '<span class="pointer"><i class="icon-refresh pointer" ng-click="refresh()"></i></span>';
        $scope.template = $compile(templateHTML)($scope);
    });
    
    0 讨论(0)
提交回复
热议问题