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

后端 未结 3 704
甜味超标
甜味超标 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:38

    To manually remove the element do an element.remove(). Sounds like you also want to destroy the scope of your compiled element so you can do that too by doing scope.$destroy(); or $scope.$destroy(); depending on if you're in a directive or not.

    http://docs.angularjs.org/api/ng.$rootScope.Scope#$destroy

提交回复
热议问题