每当我在其自身中使用指令时,页面就会冻结,并占用越来越多的 CPU 和 RAM,直到选项卡挂起。
我有的是这个
Application.Directives.directive('somed', function() {
return {
restrict: 'E',
// Load the template from a separate HTML file
templateUrl: 'directives/somed/view.html',
replace: true
};
});
和模板之类的
<div ng-if="nonexistent">
<somed></somed>
</div>
永远不应该加载嵌套指令(ng-if 评估为 false,因此不显示任何内容。如果我放置 div 标签而不是 somed,则可以确认这一点)。然而,浏览器挂在它上面。
怎么会,我该如何预防?