@@ -836,19 +836,7 @@ function encodeUriSegment(val) {
836
836
* This section explains how to bootstrap your application with angular, using either the angular
837
837
* javascript file, or manually.
838
838
*
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`
852
840
* The simplest way to get an <angular/> application up and running is by inserting a script tag in
853
841
* your HTML file that bootstraps the `http://code.angularjs.org/angular-x.x.x.min.js` code and uses
854
842
* the special `ng:autobind` attribute, like in this snippet of HTML:
@@ -866,9 +854,13 @@ function encodeUriSegment(val) {
866
854
</html>
867
855
* </pre>
868
856
*
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"`.
872
864
*
873
865
*
874
866
* ## Auto-bootstrap with `#autobind`
@@ -893,6 +885,8 @@ function encodeUriSegment(val) {
893
885
*
894
886
* In this case it's the `#autobind` URL fragment that tells angular to auto-bootstrap.
895
887
*
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`.
896
890
*
897
891
* ## Filename Restrictions for Auto-bootstrap
898
892
* 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) {
926
920
<script type="text/javascript" src="http://code.angularjs.org/angular-0.9.3.min.js"
927
921
ng:autobind></script>
928
922
<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);
935
926
</script>
936
927
</head>
937
928
<body>
@@ -973,10 +964,12 @@ function encodeUriSegment(val) {
973
964
* APIs are bound to fields of this global object.
974
965
*
975
966
*/
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 } ) ) ,
980
973
$browser = scope . $service ( '$browser' ) ;
981
974
982
975
if ( config . css )
0 commit comments