AngularJS data bind in ng-bind-html?

后端 未结 3 505
走了就别回头了
走了就别回头了 2020-11-29 07:57

Is it possible to bind data of scope variable to a html that is about to bind as ng-bind-html?

ie, I have a

html =\"
{{caption}}
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 08:25

    You need to compile your HTML snippet, but it is recommended to do that inside the directive.

    app.controller('MyCtrl', function($compile){
      $scope.caption = 'My Caption';
      $scope.html = $compile('
    {{caption}}
    ')($scope); });

提交回复
热议问题