Angularjs: how to close ng-if in a comment block?
<div ng-if="true">visible</div> pretty easy, but since ngIf can even be used in comments, what would be the closure </div> for the comment block?
I tried, without luck:
<!-- ng-if: true --> .... <!-- ng-if --> Thank.
ng-if limited to 'A' . therefore, it can only be used as an attribute, you cannot use in a comment. Here is the angular js code for ngIf
var ngIfDirective = ['$animate', function($animate) { return { transclude: 'element', priority: 600, terminal: true, restrict: 'A', // --> This means restricting to Attribute The restrict parameter usually has the value: 'E' , 'A' , 'C' , 'M'
One of the EACM limits the directive to a specific style of declaration of the directive. If you don't restrict any, the defaults (elements and attributes) are 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 -->