diff options
| author | Jeff Cross | 2013-07-24 10:17:24 -0700 | 
|---|---|---|
| committer | Jeff Cross | 2013-08-09 13:14:12 -0700 | 
| commit | 3ee744cc63a24b127d6a5f632934bb6ed2de275a (patch) | |
| tree | d66bab80608d1ef959fd7fd871e9493dad24d928 /docs/content/error/ng/btstrpd.ngdoc | |
| parent | 94ec84e7b9c89358dc00e4039009af9e287bbd05 (diff) | |
| download | angular.js-3ee744cc63a24b127d6a5f632934bb6ed2de275a.tar.bz2 | |
fix(re-bootstrap): Throw an error when bootstrapping a bootstrapped element.
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.
Diffstat (limited to 'docs/content/error/ng/btstrpd.ngdoc')
| -rw-r--r-- | docs/content/error/ng/btstrpd.ngdoc | 29 | 
1 files changed, 29 insertions, 0 deletions
| diff --git a/docs/content/error/ng/btstrpd.ngdoc b/docs/content/error/ng/btstrpd.ngdoc new file mode 100644 index 00000000..401e2767 --- /dev/null +++ b/docs/content/error/ng/btstrpd.ngdoc @@ -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> +``` | 
