Skip to content

Commit 5044238

Browse files
committed
docs(ngShow): calirfy info about the .ng-hide class and the display style
1 parent 7c011e7 commit 5044238

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

src/ng/directive/ngShowHide.js

+31-20
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,23 +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 {
4350
* /&#42; this is just another form of hiding an element &#42;/
51+
* display:block!important;
4452
* position:absolute;
4553
* top:-9999px;
4654
* left:-9999px;
4755
* }
4856
* ```
4957
*
50-
* Just remember to include the important flag so the CSS override will function.
51-
*
52-
* <div class="alert alert-warning">
53-
* **Note:** Here is a list of values that ngShow will consider as a falsy value (case insensitive):<br />
54-
* "f" / "0" / "false" / "no" / "n" / "[]"
55-
* </div>
58+
* By default you don't need to override in CSS anything and the animations will work around the display style.
5659
*
5760
* ## A note about animations with ngShow
5861
*
@@ -83,6 +86,9 @@
8386
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
8487
* ```
8588
*
89+
* Keep in mind that, as of AngularJS version 1.3.0-beta.11, there is no need to change the display
90+
* property to block during animation states--ngAnimate will handle the style toggling automatically for you.
91+
*
8692
* @animations
8793
* addClass: .ng-hide - happens after the ngShow expression evaluates to a truthy value and the just before contents are set to visible
8894
* removeClass: .ng-hide - happens after the ngShow expression evaluates to a non truthy value and just before the contents are set to hidden
@@ -186,6 +192,11 @@ var ngShowDirective = ['$animate', function($animate) {
186192
* on the element causing it to become hidden. When false, the ng-hide CSS class is removed
187193
* from the element causing the element not to appear hidden.
188194
*
195+
* <div class="alert alert-warning">
196+
* **Note:** Here is a list of values that ngHide will consider as a falsy value (case insensitive):<br />
197+
* "f" / "0" / "false" / "no" / "n" / "[]"
198+
* </div>
199+
*
189200
* ## Why is !important used?
190201
*
191202
* You may be wondering why !important is used for the .ng-hide CSS class. This is because the `.ng-hide` selector
@@ -199,30 +210,27 @@ var ngShowDirective = ['$animate', function($animate) {
199210
*
200211
* ### Overriding .ng-hide
201212
*
202-
* If you wish to change the hide behavior with ngShow/ngHide then this can be achieved by
203-
* restating the styles for the .ng-hide class in CSS:
213+
* By default, the `.ng-hide` class will style the element with `display:none!important`. If you wish to change
214+
* the hide behavior with ngShow/ngHide then this can be achieved by restating the styles for the `.ng-hide`
215+
* class in CSS:
216+
*
204217
* ```css
205218
* .ng-hide {
206-
* //this is just another form of hiding an element
219+
* /&#42; this is just another form of hiding an element &#42;/
220+
* display:block!important;
207221
* position:absolute;
208222
* top:-9999px;
209223
* left:-9999px;
210224
* }
211225
* ```
212226
*
213-
* Just remember to include the important flag so the CSS override will function.
214-
*
215-
* <div class="alert alert-warning">
216-
* **Note:** Here is a list of values that ngHide will consider as a falsy value (case insensitive):<br />
217-
* "f" / "0" / "false" / "no" / "n" / "[]"
218-
* </div>
227+
* By default you don't need to override in CSS anything and the animations will work around the display style.
219228
*
220229
* ## A note about animations with ngHide
221230
*
222231
* Animations in ngShow/ngHide work with the show and hide events that are triggered when the directive expression
223-
* is true and false. This system works like the animation system present with ngClass, except that
224-
* you must also include the !important flag to override the display property so
225-
* that you can perform an animation when the element is hidden during the time of the animation.
232+
* is true and false. This system works like the animation system present with ngClass, except that the `.ng-hide`
233+
* CSS class is added and removed for you instead of your own CSS class.
226234
*
227235
* ```css
228236
* //
@@ -238,6 +246,9 @@ var ngShowDirective = ['$animate', function($animate) {
238246
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
239247
* ```
240248
*
249+
* Keep in mind that, as of AngularJS version 1.3.0-beta.11, there is no need to change the display
250+
* property to block during animation states--ngAnimate will handle the style toggling automatically for you.
251+
*
241252
* @animations
242253
* removeClass: .ng-hide - happens after the ngHide expression evaluates to a truthy value and just before the contents are set to hidden
243254
* 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)