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

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

问题描述

< D​​IV NG-IF =真正的>可见< / DIV> 是pretty容易,但由于的 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?

试过了,W / O运气:

Tried, w/o luck:

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

感谢。

推荐答案

NG-如果仅限于'A'。所以它只能用来作定语,你不能在评论使用这里的angularjs code为ngIf

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

限制选项通常设置为:'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.

电子 - 元素名称(默认):&LT;我的指导性和GT;&LT; /我-指令&GT;

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

A - 属性(默认):&LT; D​​IV我-指令=EXP&GT;&LT; / DIV&GT;

A - Attribute (default): <div my-directive="exp"></div>

C - 等级:&LT; D​​IV CLASS =我-指令:EXP;&GT;&LT; / DIV&GT;

M - 评论:&LT; - 指令:!我-指令EXP - &GT;

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

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