angularjs - The angular documentation says that restrict applies to attributes (A) and elements (E). The source code says (AC) - why? -
the angular documentation says restrict applies attributes (a) , elements (e).
restrict
string of subset of eacm restricts directive specific directive declaration style. if omitted, defaults (elements , attributes) used.
e - element name (default):
<my-directive></my-directive>
a - attribute (default):
<div my-directive="exp"></div>
c - class:
<div> class="my-directive: exp;"></div>
m - comment:
<!-- directive: my-directive exp -->
the source code says (ac) - why discrepancy, or misreading code?
function ngdirective(directive) { if (isfunction(directive)) { directive = { link: directive }; } directive.restrict = directive.restrict || 'ac'; // here return valuefn(directive); }
directives you create yourself restricted being used elements or attributes default.
the registerdirective
function in compile.js
contains code relevant documentation snippet you've posted (i.e. custom directives default restrict
elements , attributes).
and @jhecht mentioned, it's built-in directives (i.e. ng-repeat
, ng-style
, etc.) restricted attributes , comments default.
Comments
Post a Comment