Nested Break Angular Directives

Whenever I use the directive inside myself, the page freezes and consumes more and more processor and RAM until the tab freezes.

I have it

Application.Directives.directive('somed', function() {
    return {
        restrict: 'E',
        // Load the template from a separate HTML file
        templateUrl: 'directives/somed/view.html',
        replace: true
    };
});

and template for example

<div ng-if="nonexistent">
    <somed></somed>
</div>

Which should never load a nested directive (the ng-if value is false, so the content is not displayed. This is confirmed if I put the div tag instead of somed). However, the browser is hanging on it.

Why, and how can I prevent it?

+4
source share
2 answers

The documentation ng-ifreads:

It also ngIfrecreates the elements using their compiled state.

somed somed, . .

, .

+1

:

var iAmAlwaysTrue = true;

function test(){
    if(iAmAlwaysTrue)
        test();
} // end test

test();

, AngularJS . ++, ++ ?

EDIT: , , AngularJS , , , , , , Angular ng-? - , , .

-2

All Articles