-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Is there a way to "unbootstrap" an element & module? #6180
Comments
AFAIK, not easily. Your could clone the DOM tree, remove the bootstrapped bits, and then add the cloned DOM back in. What is it that you're trying to do? There might be a better approach. |
I am using Rendr, which is like a Backbone app. Each view is "recreated" every time a user interacts with the page. Everytime I render the page, my "initialize" creates an angular.module(...) to bootstrap the app & its controllers. angular.bootstrap re-adds them (an entirely new instance of DOMelement, yet same contents & etc) and causes an "already boostrapped" error Rendr uses Backbone routes in client, so I can't really use angular routes to manage things. |
I don't think Rendr is meant to be used with Angular. Angular should manage DOM updates for your app. If you're constantly disabling this feature (by un-bootstrapping the app), why use Angular at all? Is there something I'm missing? |
We're planning using AngularJS for its dom-binding features, modularity and scalability. What I was planning to do is to have major views bootstrap a nested app while inside the global ng-app (body). In initial load, load all global services in parent ng-app. Then on every view-initialize, bootstrap a nested app, then once the view gets trashed, unbootstrap it, while keeping the parent ng-app intact. I need to unbootstrap it to clean resources. With regards to Rendr, if a site is visited directly by its url, Rendr uses Express in backend (for SEO). If a user visits links through the site, it uses Backbone. Perhaps I can do a fork to use Angular's router instead of backbone's. Another possible solution (i think) is to load controllers, factories, services, etc dynamically. Would that be possible with AngularJS? Basically if(notExists)loadThisController() Not entirely sure how to get around this. I'm building the foundation of a very big enterprise "webapp." And I am stuck with Rendr, so I cannot convert to Express/Angular stack freely. |
@jancarloviray you could lazily load code and instantiate it with The only way to "unbootstrap" parts of angular are to remove it from the DOM. The good news is that angular does the cleanup for you, so long as you use scopes and jQuery/jqLite's I'd recommend checking out StackOverflow or the IRC channel for more advice. This is possible, but it's outside the scope of angular core. Closing this issue. |
I bootstrap an element & module with this:
angular.bootstrap(elemenent, ['appName']);
What if I want to "unbootstrap" it?
The text was updated successfully, but these errors were encountered: