All we need is an easy explanation of the problem, so here it is.
<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?
Tried, w/o luck:
<!-- ng-if: true -->
....
<!-- ng-if -->
Thanks.
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
Method 1
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
The restrict
option is typically set to: 'E'
,'A'
,'C'
,'M'
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
– 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 -->
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0