See $compile
. You can use this service similarly to this:
var newDirective = angular.element('<div d2></div>');
element.append(newDirective);
$compile(newDirective)($scope);
This will perform the compilation and linking of your new element, and set d2
into action.
However you may find it simpler and more angular if you can somehow rewrite your original directive in terms of other built in directives like ng-repeat
or ng-include
that will perform the compile and link for you.
If your directive is simple enough it could just do something along the lines of adding to an array when hearing your event, and specify a template like
<div ng-repeat="evt in recordedEvents">
<div d2="evt"></div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…