This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(re-bootstrap): Throw an error when bootstrapping a bootstrapped e…
…lement. Nothing would prevent a user from accidentally calling angular.bootstrap on an element that had already been bootstrapped. If this was done, odd behavior could manifest in an application, causing different scopes to update the same DOM, and causing debugger confusion. This fix adds a check inside of angular.bootstrap to check if the passed-in element already has an injector, and if so, will throw an error.
- Loading branch information
1 parent
94ec84e
commit 3ee744c
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@ngdoc error | ||
@name ng:btstrpd | ||
@fullName App Already Bootstrapped with this Element | ||
@description | ||
|
||
Occurs when calling angular.bootstrap on an element that has already been bootstrapped. | ||
|
||
This usually happens when you accidentally use both `ng-app` and `angular.bootstrap` to bootstrap an application. | ||
|
||
``` | ||
<html> | ||
... | ||
<body ng-app="myApp"> | ||
<script> | ||
angular.bootstrap(document.body, ['myApp']); | ||
</script> | ||
</body> | ||
</html> | ||
``` | ||
|
||
Note that for bootrapping purposes, the `<html>` element is the same as `document`, so the following will also throw an error. | ||
``` | ||
<html> | ||
... | ||
<script> | ||
angular.bootstrap(document, ['myApp']); | ||
</script> | ||
</html> | ||
``` |
This file contains 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
This file contains 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
3ee744c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The demo on this documentation page is broken because of this commit: http://docs.angularjs.org/guide/dev_guide.services.$location
It is trying to bootstrap two sub-elements of the overall application but is now failing because we are deeming those elements to be bootstrapped already - even though they are wrapped in an element which has ng-nonbindable on it