Created
March 1, 2015 23:29
-
-
Save goldalworming/a90b69937d4fbe3de881 to your computer and use it in GitHub Desktop.
destroy scope example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var newScope = scope.$new(); // create a new scope from the current scope | |
| var content = $compile(template)(newScope); // compile and link to the new scope | |
| element.append(content); // add to the DOM | |
| // .. then later, we want to update the content of the element ... | |
| newScope.$destroy(); // destroy the scope and all child scopes | |
| var newScope2 = scope.$new(); // create a new scope | |
| var content2 = $compile(template2)(newScope2); // compile and link | |
| content.replaceWith(content2); // replace the html content with the new content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment