Angularjs:如何在注释块中关闭 ng-if? [英] Angularjs: how to close ng-if in comment block?

查看:23
本文介绍了Angularjs:如何在注释块中关闭 ng-if?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<div ng-if="true">visible</div> 非常简单,但是由于 ngIf 甚至可以在注释中使用,注释块的结束 </div> 是什么?

<div ng-if="true">visible</div> is pretty easy, but since ngIf can be used even in comments, what would be the closing </div> for comment block?

尝试过,没有运气:

<!-- ng-if: true -->
....
<!-- ng-if -->

谢谢.

推荐答案

ng-if 仅限于 'A'.所以只能作为属性使用,不能在注释中使用这里是ngIf的angularjs代码

ng-if is restricted to 'A'. so it can be used only as attribute, you can't use in comment Here's the angularjs code for ngIf

var ngIfDirective = ['$animate', function($animate) {
  return {
    transclude: 'element',
    priority: 600,
    terminal: true,
    restrict: 'A',       // --> This means restricting to Attribute

restrict 选项通常设置为:'E','A','C','M'

The restrict option is typically set to: 'E','A','C','M'

EACM 之一将指令限制为特定的指令声明样式.如果您不限制任何,则使用默认值(元素和属性).

One of EACM restricts the directive to a specific directive declaration style. If you don't restrict any, the defaults (elements and attributes) are used.

E - 元素名称(默认):

E - Element name (default): <my-directive></my-directive>

A - 属性(默认):<div my-directive="exp"></div>

C - 类:<div class="my-directive: exp;"></div>

M - 注释:<!-- 指令:my-directive exp -->

这篇关于Angularjs:如何在注释块中关闭 ng-if?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆