<div overlay config="overlayConfig">
<div class="dismiss-buttons">
<button class="btn btn-default" ng-click="subscriptions()">Save</button>
</div>
</div>
app.directive("Overlay", ["$timeout", "$compile", function($timeout, $compile) {
return {
restrict: "A",
transclude: true,
scope: {
config: "="
},
template: "<div class='overlay'><div ng-transclude></div></div>",
link: function(scope, iElement, iAttrs, ctrl, transclude) {
iElement = iElement.find(".ehn-overlay");
$(document.body).append(iElement);
scope.$watchCollection("config", function(value) {
if (scope.config.isVisible === false) {
iElement.remove();
} else {
$(document.body).append(iElement);
}
});
}
};
}]);
我需要将覆盖层附加到主体上,一旦完成就将其删除。它第一次工作,但下次我附加它时不会触发 ng-click,所以我假设它没有被编译。有人可以在这里给出解决方案吗?