بالنسبة للمستخدمين العاديين ، يرتبط AgularJS's 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 <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 أيضًا واجهة برمجة تطبيقات ملزمة يدويًا - تم استخدامها على النحو التالي:
Angular.Bootstrap (العنصر ، [الوحدات النمطية] ، [config]) ؛
عنصر المعلمة الأول: هو عنصر DOM الذي يربط NG-APP ؛
الوحدات النمطية: اسم الوحدة النمطية
التكوين: تكوين إضافي
نظرة قصيرة على الرمز:
<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 ، Angular from bootstrap" ؛}) ؛ // Angular.Bootstrap (document.getElementById ("body") ، ['bootstraptest']) ؛ Angular.Bootstrap (وثيقة ، ['bootstraptest']) ؛ </script> </body> </html>تجدر الإشارة إلى:
angular.bootstrap سوف يربط فقط الكائن المحمّل الأول.
سيتم إخراج الروابط المتكررة اللاحقة أو الكائنات الأخرى مطالبات الخطأ على وحدة التحكم.
ما سبق هو المعلومات التي تخرج من bootstrap AngularJS. سنستمر في إضافة المعلومات ذات الصلة في المستقبل. شكرا لك على دعمك لهذا الموقع!