5

I want to delay ngOndestroy hook calling since I am facing one issue which is i have created angular application, in that I have used animation.

sample - https://stackblitz.com/edit/angular-iribr7-zorjpc?file=app.component.html

When I press toggl button, my components get displayed with animation. When I press that button 2nd time, my component get destroyed before animation.

In my components ngOndestroy hooka I have used below:

    ComponentBase.prototype.ngOnDestroy = function () {
        /* istanbul ignore else  */
        if (typeof window !== 'undefined' && this.element.classList.contains('e-control')) { 
        /* used to delete DOM element to avoid memory leak */
            this.destroy(); 
        /* used to delete template refrences to avoid memory leak */
            this.clearTemplate(null);  ------> used 
        }
    };

I have tried settimeout method also, while using setTimout it works fine while debugging but with out that same issue again

I am expecting any other work around or suggestion to resolve this.....

I tried like below but no luck for me----------

https://stackblitz.com/edit/angular-iribr7-bxvnwg?file=app.component.html

4

0 回答 0