تصف هذه المقالة طريقة AngularJS باستخدام التوجيهات المخصصة التوجيهية لتنفيذ ميراث السمة. شاركه للرجوع إليه ، على النحو التالي:
1. رمز HTML:
<! doctype html> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html ؛ src = "../../ content/plugins/Angular/Angular.min.js"> </script> </head> <body ng-app = "mainapp" ng-controller = "mainController"> <quber-grid style = "border: 1px sold #f00 ؛
2. ملف tmp.html
<div quber-grid-attr> أنا محتوى القالب للاختبار! </div>
3. رمز JS:
// تهيئة الكائن الزاوي var myng = Angular.module ('mainapp' ، []) ؛ myng.directive ('QuberGrid' ، function () {return {restrict: 'ea' ، replace: rue ، // refled the <quber-grid> tag tamplateurl: 'tmp.html' الحدث المسمى sendchildgridattr sco. $ broadcast ('sendchildgridattr' ، attr) ؛ (VAL ، OBJ) {if (key! = $ attr '&& key! =' $$ element ') }} ؛ }} ؛ }) ؛ myng.controller ('MainController' ، function ($ scope) {}) ؛الآثار هي كما يلي:
آمل أن تكون هذه المقالة مفيدة لبرمجة AngularJS للجميع.