NG-APPのAngularJS手動DOM要素に結合され、平均的なユーザーのために。ただし、一部のアプリケーションでは、それは非常に便利です。
バインディングの初期化
角度の結合によって初期化され、それはHTMLでJSコードに侵入だろうが、初心者が使用するため、それは十分でした!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="myCtrl">
{{ hello }}
</div>
<script type="text/javascript">
var myModule = angular.module("myApp",[]);
myModule.controller("myCtrl",function($scope){
$scope.hello = "hello,angular!";
});
</script>
</body>
</html>
実行後、表示されます。hello,angular!
マニュアル初期化
:次のようにその使用は、ブートストラップ - の角度も手動バインディングAPIを提供しました
angular.bootstrap(element, [modules], [config]);
第1のパラメータ要素:NG-アプリ結合DOM要素である
モジュール:モジュール名バインディング
設定:追加の構成
単純にコードを見て:
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script>
<body id="body">
<div ng-controller="myCtrl">
{{ hello }}
</div>
<script type="text/javascript">
var app = angular.module("bootstrapTest",[]);
app.controller("myCtrl",function($scope){
$scope.hello = "hello,angular from bootstrap";
});
// angular.bootstrap(document.getElementById("body"),['bootstrapTest']);
angular.bootstrap(document,['bootstrapTest']);
</script>
</body>
</html>
それは注目に値します。
- angular.bootstrap唯一のバインディングオブジェクトが最初にロードされました。
- コンソールにエラーメッセージを出力しますが、結合バックを繰り返したり、他のオブジェクトをバインドします。
ます。https://my.oschina.net/u/204616/blog/545207で再現