Angular - How can I remove from the DOM an element I have used $compile on?

后端 未结 3 666
甜味超标
甜味超标 2021-02-05 07:17

What I need is the functionality of two ng-views. Because I can\'t I want to change the innerHTML of something and compile it. The problem I have is when I change the content ag

3条回答
  •  一向
    一向 (楼主)
    2021-02-05 07:31

    The solution for this problem is creating a new child scope. All bindings with parent scope work because of scope Inheritance. When I need to change the content, I simply destroy the child scope, avoiding memory leaks.

    I've also made and getter and setter methods for the child scope to avoid poluting que parent scope, in case the other content uses disposable variables

提交回复
热议问题