Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 669e3ae

Browse files
committed
docs(ngShow): calirfy info about the .ng-hide class and the display style
1 parent 55b2f0e commit 669e3ae

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

src/ng/directive/ngShowHide.js

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
* on the element causing it to become hidden. When true, the ng-hide CSS class is removed
2424
* from the element causing the element not to appear hidden.
2525
*
26+
* <div class="alert alert-warning">
27+
* **Note:** Here is a list of values that ngShow will consider as a falsy value (case insensitive):<br />
28+
* "f" / "0" / "false" / "no" / "n" / "[]"
29+
* </div>
30+
*
2631
* ## Why is !important used?
2732
*
2833
* You may be wondering why !important is used for the .ng-hide CSS class. This is because the `.ng-hide` selector
@@ -36,24 +41,21 @@
3641
*
3742
* ### Overriding .ng-hide
3843
*
39-
* If you wish to change the hide behavior with ngShow/ngHide then this can be achieved by
40-
* restating the styles for the .ng-hide class in CSS:
44+
* By default, the `.ng-hide` class will style the element with `display:none!important`. If you wish to change
45+
* the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide`
46+
* class in CSS:
47+
*
4148
* ```css
4249
* .ng-hide {
43-
* /&#42; this is just another form of hiding an element &#42;/
50+
* //this is just another form of hiding an element
4451
* display:block!important;
4552
* position:absolute;
4653
* top:-9999px;
4754
* left:-9999px;
4855
* }
4956
* ```
5057
*
51-
* Just remember to include the important flag so the CSS override will function.
52-
*
53-
* <div class="alert alert-warning">
54-
* **Note:** Here is a list of values that ngShow will consider as a falsy value (case insensitive):<br />
55-
* "f" / "0" / "false" / "no" / "n" / "[]"
56-
* </div>
58+
* By default you don't need to override in CSS anything and the animations will work around the display style.
5759
*
5860
* ## A note about animations with ngShow
5961
*
@@ -76,6 +78,9 @@
7678
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
7779
* ```
7880
*
81+
* Keep in mind that, as of AngularJS version 1.2.17 (and 1.3.0-beta.11), there is no need to change the display
82+
* property to block during animation states--ngAnimate will handle the style toggling automatically for you.
83+
*
7984
* @animations
8085
* addClass: .ng-hide - happens after the ngShow expression evaluates to a truthy value and the just before contents are set to visible
8186
* removeClass: .ng-hide - happens after the ngShow expression evaluates to a non truthy value and just before the contents are set to hidden
@@ -175,6 +180,11 @@ var ngShowDirective = ['$animate', function($animate) {
175180
* on the element causing it to become hidden. When false, the ng-hide CSS class is removed
176181
* from the element causing the element not to appear hidden.
177182
*
183+
* <div class="alert alert-warning">
184+
* **Note:** Here is a list of values that ngHide will consider as a falsy value (case insensitive):<br />
185+
* "f" / "0" / "false" / "no" / "n" / "[]"
186+
* </div>
187+
*
178188
* ## Why is !important used?
179189
*
180190
* You may be wondering why !important is used for the .ng-hide CSS class. This is because the `.ng-hide` selector
@@ -188,30 +198,27 @@ var ngShowDirective = ['$animate', function($animate) {
188198
*
189199
* ### Overriding .ng-hide
190200
*
191-
* If you wish to change the hide behavior with ngShow/ngHide then this can be achieved by
192-
* restating the styles for the .ng-hide class in CSS:
201+
* By default, the `.ng-hide` class will style the element with `display:none!important`. If you wish to change
202+
* the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide`
203+
* class in CSS:
204+
*
193205
* ```css
194206
* .ng-hide {
195207
* //this is just another form of hiding an element
208+
* display:block!important;
196209
* position:absolute;
197210
* top:-9999px;
198211
* left:-9999px;
199212
* }
200213
* ```
201214
*
202-
* Just remember to include the important flag so the CSS override will function.
203-
*
204-
* <div class="alert alert-warning">
205-
* **Note:** Here is a list of values that ngHide will consider as a falsy value (case insensitive):<br />
206-
* "f" / "0" / "false" / "no" / "n" / "[]"
207-
* </div>
215+
* By default you don't need to override in CSS anything and the animations will work around the display style.
208216
*
209217
* ## A note about animations with ngHide
210218
*
211219
* Animations in ngShow/ngHide work with the show and hide events that are triggered when the directive expression
212-
* is true and false. This system works like the animation system present with ngClass, except that
213-
* you must also include the !important flag to override the display property so
214-
* that you can perform an animation when the element is hidden during the time of the animation.
220+
* is true and false. This system works like the animation system present with ngClass, except that the `.ng-hide`
221+
* CSS class is added and removed for you instead of your own CSS class.
215222
*
216223
* ```css
217224
* //
@@ -227,6 +234,9 @@ var ngShowDirective = ['$animate', function($animate) {
227234
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
228235
* ```
229236
*
237+
* Keep in mind that, as of AngularJS version 1.2.17 (and 1.3.0-beta.11), there is no need to change the display
238+
* property to block during animation states--ngAnimate will handle the style toggling automatically for you.
239+
*
230240
* @animations
231241
* removeClass: .ng-hide - happens after the ngHide expression evaluates to a truthy value and just before the contents are set to hidden
232242
* addClass: .ng-hide - happens after the ngHide expression evaluates to a non truthy value and just before the contents are set to visible

0 commit comments

Comments
 (0)