ng-if
仅限于'A'
。所以它只能用作属性,不能在注释中使用这是 ngIf 的 angularjs 代码
var ngIfDirective = ['$animate', function($animate) {
return {
transclude: 'element',
priority: 600,
terminal: true,
restrict: 'A', // --> This means restricting to Attribute
The restrict
选项通常设置为:'E'
,'A'
,'C'
,'M'
One of EACM
将指令限制为特定的指令声明样式。If you don't restrict any, the defaults (elements and attributes) are used
.
E
- 元素名称(默认):<my-directive></my-directive>
A
- 属性(默认):<div my-directive="exp"></div>
C
- 班级:<div class="my-directive: exp;"></div>
M
- 评论:<!-- directive: my-directive exp -->