$sce.trustAsHtml
and ng-bind-html
are not meant to build HTML with directives. This technique will not work.
This is because angular works by first compiling and then linking. See the conceptual overview for a good explaination.
In short, by the time you link the HTML defined in your trustAsHtml
, it is too late for angular to compile (and therefore understand) the ng-click
directive.
In order to dynamically add HTML, you should be looking at the $compile
service (and/or directives). Docs are here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…