@@ -836,19 +836,7 @@ function encodeUriSegment(val) {
836836 * This section explains how to bootstrap your application with angular, using either the angular
837837 * javascript file, or manually.
838838 *
839- *
840- * ## The angular distribution
841- * Note that there are two versions of the angular javascript file that you can use:
842- *
843- * * `angular.js` - the development version - this file is unobfuscated, uncompressed, and thus
844- * human-readable and useful when developing your angular applications.
845- * * `angular.min.js` - the production version - this is a minified and obfuscated version of
846- * `angular.js`. You want to use this version when you want to load a smaller but functionally
847- * equivalent version of the code in your application. We use the Closure compiler to create this
848- * file.
849- *
850- *
851- * ## Auto-bootstrap with `ng:autobind`
839+ * # Auto-bootstrap with `ng:autobind`
852840 * The simplest way to get an <angular/> application up and running is by inserting a script tag in
853841 * your HTML file that bootstraps the `http://code.angularjs.org/angular-x.x.x.min.js` code and uses
854842 * the special `ng:autobind` attribute, like in this snippet of HTML:
@@ -866,9 +854,13 @@ function encodeUriSegment(val) {
866854 </html>
867855 * </pre>
868856 *
869- * The `ng:autobind` attribute tells <angular/> to compile and manage the whole HTML document. The
870- * compilation occurs in the page's `onLoad` handler. Note that you don't need to explicitly add an
871- * `onLoad` event; auto bind mode takes care of all the magic for you.
857+ * The `ng:autobind` attribute without any value tells angular to compile and manage the whole HTML
858+ * document. The compilation occurs as soon as the document is ready for DOM manipulation. Note that
859+ * you don't need to explicitly add an `onLoad` event handler; auto bind mode takes care of all the
860+ * work for you.
861+ *
862+ * In order to compile only a part of the document, specify the id of the element that should be
863+ * compiled as the value of the `ng:autobind` attribute, e.g. `ng:autobind="angularContent"`.
872864 *
873865 *
874866 * ## Auto-bootstrap with `#autobind`
@@ -893,6 +885,8 @@ function encodeUriSegment(val) {
893885 *
894886 * In this case it's the `#autobind` URL fragment that tells angular to auto-bootstrap.
895887 *
888+ * Similarly to `ng:autobind`, you can specify an element id that should be exclusively targeted for
889+ * compilation as the value of the `#autobind`, e.g. `#autobind=angularContent`.
896890 *
897891 * ## Filename Restrictions for Auto-bootstrap
898892 * In order for us to find the auto-bootstrap script attribute or URL fragment, the value of the
@@ -926,12 +920,9 @@ function encodeUriSegment(val) {
926920 <script type="text/javascript" src="http://code.angularjs.org/angular-0.9.3.min.js"
927921 ng:autobind></script>
928922 <script type="text/javascript">
929- (function(window, previousOnLoad){
930- window.onload = function(){
931- try { (previousOnLoad||angular.noop)(); } catch(e) {}
932- angular.compile(window.document);
933- };
934- })(window, window.onload);
923+ (angular.element(document).ready(function() {
924+ angular.compile(document)();
925+ })(document);
935926 </script>
936927 </head>
937928 <body>
@@ -973,10 +964,12 @@ function encodeUriSegment(val) {
973964 * APIs are bound to fields of this global object.
974965 *
975966 */
976- function angularInit ( config ) {
977- if ( config . autobind ) {
978- // TODO default to the source of angular.js
979- var scope = compile ( window . document ) ( createScope ( { '$config' :config } ) ) ,
967+ function angularInit ( config , document ) {
968+ var autobind = config . autobind ;
969+
970+ if ( autobind ) {
971+ var element = isString ( autobind ) ? document . getElementById ( autobind ) : document ,
972+ scope = compile ( element ) ( createScope ( { '$config' :config } ) ) ,
980973 $browser = scope . $service ( '$browser' ) ;
981974
982975 if ( config . css )
0 commit comments