Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger $destroy on jqLite elements #36

Open
cozmy opened this issue Feb 26, 2020 · 0 comments
Open

Trigger $destroy on jqLite elements #36

cozmy opened this issue Feb 26, 2020 · 0 comments

Comments

@cozmy
Copy link

cozmy commented Feb 26, 2020

Currently, componentWillUnmount only calls this.state.scope.$destroy().
It should also "destroy" the compiled element so $destroy is trigger: https://docs.angularjs.org/api/ng/function/angular.element#events

$destroy - AngularJS intercepts all jqLite/jQuery's DOM destruction apis and fires this event on all DOM nodes being removed. This can be used to clean up any 3rd party bindings to the DOM element before it is removed.

3rd party libraries depend on this: see $mdMenu fron AngularJS Material.

How to implement:

  1. In compile do: this.setState({ compiledElement: $injector.get('$compile')(element)(this.state.scope) });
  2. In componentWillUnmount do angular.element(this.state.compiledElement).empty();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant