Skip to content

Instantly share code, notes, and snippets.

@goldalworming
Created March 1, 2015 23:29
Show Gist options
  • Select an option

  • Save goldalworming/a90b69937d4fbe3de881 to your computer and use it in GitHub Desktop.

Select an option

Save goldalworming/a90b69937d4fbe3de881 to your computer and use it in GitHub Desktop.
destroy scope example
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