<div ng-if="true">visible</div>很容易,但是由于ngIf甚至可以在评论中使用,所以</div>评论块的结束是什么?
试过了,没有运气:
<!-- ng-if: true -->
....
<!-- ng-if -->
谢谢。
<div ng-if="true">visible</div>很容易,但是由于ngIf甚至可以在评论中使用,所以</div>评论块的结束是什么?
试过了,没有运气:
<!-- ng-if: true -->
....
<!-- ng-if -->
谢谢。
ng-if限于'A'。所以它只能用作属性,你不能在评论中使用这是 ngIf 的 angularjs 代码
var ngIfDirective = ['$animate', function($animate) {
return {
transclude: 'element',
priority: 600,
terminal: true,
restrict: 'A', // --> This means restricting to Attribute
该restrict选项通常设置为:'E', 'A', 'C','M'
其中之一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 -->