일반 사용자의 경우 AngularJS의 NG-App은 수동으로 특정 DOM 요소에 바인딩됩니다. 그러나 일부 응용 분야에서는 불편 해 보입니다.
바인딩 초기화
바인딩을 통해 각도를 초기화하면 JS 코드가 HTML에 침해되지만 초보자가 사용하기에 충분합니다!
<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"> <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>실행 후, 안녕하세요, Angular가 표시됩니다!
수동 초기화
Angular는 또한 수동으로 바인딩 된 API- 부트 스트랩을 제공하며 다음과 같이 사용됩니다.
Angular.bootstrap (요소, [모듈], [config]);
첫 번째 매개 변수 요소 : NG-APP에 결합하는 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"> ng-controller = "myctrl"> {{hello}} </div> <script type = "text/javaScript"> var app = angular.module ( "bootstraptest", []); app.controller ( "myctrl", function ($ scope) {$ scope.hello = "hello, bootstrap의 angular";}); // angular.bootstrap (document.getElementById ( "body"), [ 'bootstraptest']); Angular.bootstrap (document, [ 'bootstraptest']); </script> </body> </html>주목할 가치가 있습니다.
Angular.bootstrap은 첫 번째로드 된 객체 만 바인딩합니다.
후속 반복 바인딩 또는 다른 객체는 콘솔에서 오류 프롬프트를 출력합니다.
위의 것은 AngularJS 부트 스트랩을 분류하는 정보입니다. 우리는 향후 관련 정보를 계속 추가 할 것입니다. 이 사이트를 지원 해주셔서 감사합니다!