@angular-wave/angular.ts 0.0.66 → 0.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/animations/animate-js.js +4 -4
- package/src/animations/animate-swap.js +3 -0
- package/src/core/compile/compile.js +3 -3
- package/src/core/controller/controller.js +0 -5
- package/src/core/di/injector.js +9 -12
- package/src/core/di/internal-injector.js +113 -60
- package/src/core/parser/parse.js +1 -12
- package/src/core/parser/parse.spec.js +96 -110
- package/src/core/timeout/timeout.js +110 -111
- package/src/directive/input/input.js +32 -726
- package/src/directive/input/input.md +706 -0
- package/src/directive/select/select.js +48 -122
- package/src/directive/select/select.md +74 -0
- package/src/directive/show-hide/show-hide.js +13 -224
- package/src/directive/show-hide/show-hide.md +257 -0
- package/src/filters/limit-to.spec.js +1 -1
- package/src/filters/order-by.spec.js +1 -1
- package/src/index.js +6 -2
- package/src/loader.js +7 -3
- package/src/public.js +1 -7
- package/src/router/state/state-builder.js +2 -4
- package/src/router/state/state-service.js +1 -1
- package/src/router/state-provider.js +1 -1
- package/src/router/template-factory.js +10 -10
- package/src/router/url/url-service.js +4 -4
- package/src/services/anchor-scroll.js +2 -2
- package/src/services/browser.js +2 -9
- package/src/services/cache-factory.js +0 -67
- package/src/services/cache-factory.md +75 -0
- package/src/services/cookie-reader.js +36 -55
- package/src/services/http/http.js +62 -587
- package/src/services/http/http.md +413 -0
- package/src/services/http-backend/http-backend.js +19 -44
- package/src/services/template-request.js +1 -9
- package/src/shared/jqlite/jqlite.js +4 -69
- package/src/types.js +2 -4
- package/types/animations/animate-swap.d.ts +4 -7
- package/types/core/compile/compile.d.ts +6 -6
- package/types/core/controller/controller.d.ts +0 -5
- package/types/core/di/internal-injector.d.ts +73 -18
- package/types/core/exception-handler.d.ts +1 -1
- package/types/core/parser/parse.d.ts +1 -1
- package/types/core/timeout/timeout.d.ts +16 -26
- package/types/directive/input/input.d.ts +19 -124
- package/types/directive/select/select.d.ts +7 -74
- package/types/directive/show-hide/show-hide.d.ts +11 -224
- package/types/loader.d.ts +4 -4
- package/types/router/state/state-builder.d.ts +1 -2
- package/types/router/state/state-service.d.ts +2 -2
- package/types/router/state-provider.d.ts +2 -2
- package/types/router/template-factory.d.ts +15 -15
- package/types/router/url/url-service.d.ts +4 -4
- package/types/services/anchor-scroll.d.ts +1 -1
- package/types/services/browser.d.ts +0 -10
- package/types/services/cache-factory.d.ts +0 -67
- package/types/services/cookie-reader.d.ts +2 -10
- package/types/services/http/http.d.ts +53 -61
- package/types/services/http-backend/http-backend.d.ts +8 -31
- package/types/services/template-request.d.ts +1 -9
- package/types/shared/jqlite/jqlite.d.ts +9 -9
- package/types/types.d.ts +1 -9
|
@@ -23,10 +23,6 @@ function setOptionSelectedStatus(optionEl, value) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @ngdoc type
|
|
27
|
-
* @name select.SelectController
|
|
28
|
-
*
|
|
29
|
-
* @description
|
|
30
26
|
* The controller for the {@link ng.select select} directive. The controller exposes
|
|
31
27
|
* a few utility methods that can be used to augment the behavior of a regular or an
|
|
32
28
|
* {@link ng.ngOptions ngOptions} select element.
|
|
@@ -371,80 +367,9 @@ function SelectController($element, $scope) {
|
|
|
371
367
|
}
|
|
372
368
|
|
|
373
369
|
/**
|
|
374
|
-
* @
|
|
375
|
-
* @name select
|
|
376
|
-
* @restrict E
|
|
377
|
-
*
|
|
378
|
-
* @description
|
|
379
|
-
* HTML `select` element with AngularJS data-binding.
|
|
380
|
-
*
|
|
381
|
-
* The `select` directive is used together with {@link ngModel `ngModel`} to provide data-binding
|
|
382
|
-
* between the scope and the `<select>` control (including setting default values).
|
|
383
|
-
* It also handles dynamic `<option>` elements, which can be added using the {@link ngRepeat `ngRepeat}` or
|
|
384
|
-
* {@link ngOptions `ngOptions`} directives.
|
|
385
|
-
*
|
|
386
|
-
* When an item in the `<select>` menu is selected, the value of the selected option will be bound
|
|
387
|
-
* to the model identified by the `ngModel` directive. With static or repeated options, this is
|
|
388
|
-
* the content of the `value` attribute or the textContent of the `<option>`, if the value attribute is missing.
|
|
389
|
-
* Value and textContent can be interpolated.
|
|
390
|
-
*
|
|
391
|
-
* The {@link select.SelectController select controller} exposes utility functions that can be used
|
|
392
|
-
* to manipulate the select's behavior.
|
|
393
|
-
*
|
|
394
|
-
* ## Matching model and option values
|
|
395
|
-
*
|
|
396
|
-
* In general, the match between the model and an option is evaluated by strictly comparing the model
|
|
397
|
-
* value against the value of the available options.
|
|
398
|
-
*
|
|
399
|
-
* If you are setting the option value with the option's `value` attribute, or textContent, the
|
|
400
|
-
* value will always be a `string` which means that the model value must also be a string.
|
|
401
|
-
* Otherwise the `select` directive cannot match them correctly.
|
|
402
|
-
*
|
|
403
|
-
* To bind the model to a non-string value, you can use one of the following strategies:
|
|
404
|
-
* - the {@link ng.ngOptions `ngOptions`} directive
|
|
405
|
-
* ({@link ng.select#using-select-with-ngoptions-and-setting-a-default-value})
|
|
406
|
-
* - the {@link ng.ngValue `ngValue`} directive, which allows arbitrary expressions to be
|
|
407
|
-
* option values ({@link ng.select#using-ngvalue-to-bind-the-model-to-an-array-of-objects Example})
|
|
408
|
-
* - model $parsers / $formatters to convert the string value
|
|
409
|
-
* ({@link ng.select#binding-select-to-a-non-string-value-via-ngmodel-parsing-formatting Example})
|
|
410
|
-
*
|
|
411
|
-
* If the viewValue of `ngModel` does not match any of the options, then the control
|
|
412
|
-
* will automatically add an "unknown" option, which it then removes when the mismatch is resolved.
|
|
413
|
-
*
|
|
414
|
-
* Optionally, a single hard-coded `<option>` element, with the value set to an empty string, can
|
|
415
|
-
* be nested into the `<select>` element. This element will then represent the `null` or "not selected"
|
|
416
|
-
* option. See example below for demonstration.
|
|
417
|
-
*
|
|
418
|
-
* ## Choosing between `ngRepeat` and `ngOptions`
|
|
419
|
-
*
|
|
420
|
-
* In many cases, `ngRepeat` can be used on `<option>` elements instead of {@link ng.directive:ngOptions
|
|
421
|
-
* ngOptions} to achieve a similar result. However, `ngOptions` provides some benefits:
|
|
422
|
-
* - more flexibility in how the `<select>`'s model is assigned via the `select` **`as`** part of the
|
|
423
|
-
* comprehension expression
|
|
424
|
-
* - reduced memory consumption by not creating a new scope for each repeated instance
|
|
425
|
-
* - increased render speed by creating the options in a documentFragment instead of individually
|
|
426
|
-
*
|
|
427
|
-
* Specifically, select with repeated options slows down significantly starting at 2000 options in
|
|
428
|
-
* Chrome and Internet Explorer / Edge.
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* @param {string} ngModel Assignable AngularJS expression to data-bind to.
|
|
432
|
-
* @param {string=} name Property name of the form under which the control is published.
|
|
433
|
-
* @param {string=} multiple Allows multiple options to be selected. The selected values will be
|
|
434
|
-
* bound to the model as an array.
|
|
435
|
-
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
|
436
|
-
* @param {string=} ngRequired Adds required attribute and required validation constraint to
|
|
437
|
-
* the element when the ngRequired expression evaluates to true. Use ngRequired instead of required
|
|
438
|
-
* when you want to data-bind to the required attribute.
|
|
439
|
-
* @param {string=} ngChange AngularJS expression to be executed when selected option(s) changes due to user
|
|
440
|
-
* interaction with the select element.
|
|
441
|
-
* @param {string=} ngOptions sets the options that the select is populated with and defines what is
|
|
442
|
-
* set on the model on selection. See {@link ngOptions `ngOptions`}.
|
|
443
|
-
* @param {string=} ngAttrSize sets the size of the select element dynamically. Uses the
|
|
444
|
-
* {@link guide/interpolation#-ngattr-for-binding-to-arbitrary-attributes ngAttr} directive.
|
|
445
|
-
*
|
|
370
|
+
* @returns {import('../../types').Directive}
|
|
446
371
|
*/
|
|
447
|
-
export
|
|
372
|
+
export function selectDirective() {
|
|
448
373
|
return {
|
|
449
374
|
restrict: "E",
|
|
450
375
|
require: ["select", "?ngModel"],
|
|
@@ -567,54 +492,55 @@ export const selectDirective = function () {
|
|
|
567
492
|
selectCtrl.writeValue(ngModelCtrl.$viewValue);
|
|
568
493
|
};
|
|
569
494
|
}
|
|
570
|
-
}
|
|
495
|
+
}
|
|
571
496
|
|
|
572
497
|
// The option directive is purely designed to communicate the existence (or lack of)
|
|
573
498
|
// of dynamically created (and destroyed) option elements to their containing select
|
|
574
499
|
// directive via its controller.
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
500
|
+
/**
|
|
501
|
+
* @returns {import('../../types').Directive}
|
|
502
|
+
*/
|
|
503
|
+
optionDirective.$inject = ["$interpolate"];
|
|
504
|
+
export function optionDirective($interpolate) {
|
|
505
|
+
return {
|
|
506
|
+
restrict: "E",
|
|
507
|
+
priority: 100,
|
|
508
|
+
compile(element, attr) {
|
|
509
|
+
let interpolateValueFn;
|
|
510
|
+
let interpolateTextFn;
|
|
511
|
+
|
|
512
|
+
if (isDefined(attr.ngValue)) {
|
|
513
|
+
// Will be handled by registerOption
|
|
514
|
+
} else if (isDefined(attr.value)) {
|
|
515
|
+
// If the value attribute is defined, check if it contains an interpolation
|
|
516
|
+
interpolateValueFn = $interpolate(attr.value, true);
|
|
517
|
+
} else {
|
|
518
|
+
// If the value attribute is not defined then we fall back to the
|
|
519
|
+
// text content of the option element, which may be interpolated
|
|
520
|
+
interpolateTextFn = $interpolate(element.text(), true);
|
|
521
|
+
if (!interpolateTextFn) {
|
|
522
|
+
attr.$set("value", element.text());
|
|
597
523
|
}
|
|
524
|
+
}
|
|
598
525
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
];
|
|
526
|
+
return function (scope, element, attr) {
|
|
527
|
+
// This is an optimization over using ^^ since we don't want to have to search
|
|
528
|
+
// all the way to the root of the DOM for every single option element
|
|
529
|
+
const selectCtrlName = "$selectController";
|
|
530
|
+
const parent = element.parent();
|
|
531
|
+
const selectCtrl =
|
|
532
|
+
parent.data(selectCtrlName) || parent.parent().data(selectCtrlName); // in case we are in optgroup
|
|
533
|
+
|
|
534
|
+
if (selectCtrl) {
|
|
535
|
+
selectCtrl.registerOption(
|
|
536
|
+
scope,
|
|
537
|
+
element,
|
|
538
|
+
attr,
|
|
539
|
+
interpolateValueFn,
|
|
540
|
+
interpolateTextFn,
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
},
|
|
545
|
+
};
|
|
546
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/\*\*
|
|
2
|
+
|
|
3
|
+
- @ngdoc directive
|
|
4
|
+
- @name select
|
|
5
|
+
- @restrict E
|
|
6
|
+
-
|
|
7
|
+
- @description
|
|
8
|
+
- HTML `select` element with AngularJS data-binding.
|
|
9
|
+
-
|
|
10
|
+
- The `select` directive is used together with {@link ngModel `ngModel`} to provide data-binding
|
|
11
|
+
- between the scope and the `<select>` control (including setting default values).
|
|
12
|
+
- It also handles dynamic `<option>` elements, which can be added using the {@link ngRepeat `ngRepeat}` or
|
|
13
|
+
- {@link ngOptions `ngOptions`} directives.
|
|
14
|
+
-
|
|
15
|
+
- When an item in the `<select>` menu is selected, the value of the selected option will be bound
|
|
16
|
+
- to the model identified by the `ngModel` directive. With static or repeated options, this is
|
|
17
|
+
- the content of the `value` attribute or the textContent of the `<option>`, if the value attribute is missing.
|
|
18
|
+
- Value and textContent can be interpolated.
|
|
19
|
+
-
|
|
20
|
+
- The {@link select.SelectController select controller} exposes utility functions that can be used
|
|
21
|
+
- to manipulate the select's behavior.
|
|
22
|
+
-
|
|
23
|
+
- ## Matching model and option values
|
|
24
|
+
-
|
|
25
|
+
- In general, the match between the model and an option is evaluated by strictly comparing the model
|
|
26
|
+
- value against the value of the available options.
|
|
27
|
+
-
|
|
28
|
+
- If you are setting the option value with the option's `value` attribute, or textContent, the
|
|
29
|
+
- value will always be a `string` which means that the model value must also be a string.
|
|
30
|
+
- Otherwise the `select` directive cannot match them correctly.
|
|
31
|
+
-
|
|
32
|
+
- To bind the model to a non-string value, you can use one of the following strategies:
|
|
33
|
+
- - the {@link ng.ngOptions `ngOptions`} directive
|
|
34
|
+
- ({@link ng.select#using-select-with-ngoptions-and-setting-a-default-value})
|
|
35
|
+
- - the {@link ng.ngValue `ngValue`} directive, which allows arbitrary expressions to be
|
|
36
|
+
- option values ({@link ng.select#using-ngvalue-to-bind-the-model-to-an-array-of-objects Example})
|
|
37
|
+
- - model $parsers / $formatters to convert the string value
|
|
38
|
+
- ({@link ng.select#binding-select-to-a-non-string-value-via-ngmodel-parsing-formatting Example})
|
|
39
|
+
-
|
|
40
|
+
- If the viewValue of `ngModel` does not match any of the options, then the control
|
|
41
|
+
- will automatically add an "unknown" option, which it then removes when the mismatch is resolved.
|
|
42
|
+
-
|
|
43
|
+
- Optionally, a single hard-coded `<option>` element, with the value set to an empty string, can
|
|
44
|
+
- be nested into the `<select>` element. This element will then represent the `null` or "not selected"
|
|
45
|
+
- option. See example below for demonstration.
|
|
46
|
+
-
|
|
47
|
+
- ## Choosing between `ngRepeat` and `ngOptions`
|
|
48
|
+
-
|
|
49
|
+
- In many cases, `ngRepeat` can be used on `<option>` elements instead of {@link ng.directive:ngOptions
|
|
50
|
+
- ngOptions} to achieve a similar result. However, `ngOptions` provides some benefits:
|
|
51
|
+
- - more flexibility in how the `<select>`'s model is assigned via the `select` **`as`** part of the
|
|
52
|
+
- comprehension expression
|
|
53
|
+
- - reduced memory consumption by not creating a new scope for each repeated instance
|
|
54
|
+
- - increased render speed by creating the options in a documentFragment instead of individually
|
|
55
|
+
-
|
|
56
|
+
- Specifically, select with repeated options slows down significantly starting at 2000 options in
|
|
57
|
+
- Chrome and Internet Explorer / Edge.
|
|
58
|
+
-
|
|
59
|
+
-
|
|
60
|
+
- @param {string} ngModel Assignable AngularJS expression to data-bind to.
|
|
61
|
+
- @param {string=} name Property name of the form under which the control is published.
|
|
62
|
+
- @param {string=} multiple Allows multiple options to be selected. The selected values will be
|
|
63
|
+
- bound to the model as an array.
|
|
64
|
+
- @param {string=} required Sets `required` validation error key if the value is not entered.
|
|
65
|
+
- @param {string=} ngRequired Adds required attribute and required validation constraint to
|
|
66
|
+
- the element when the ngRequired expression evaluates to true. Use ngRequired instead of required
|
|
67
|
+
- when you want to data-bind to the required attribute.
|
|
68
|
+
- @param {string=} ngChange AngularJS expression to be executed when selected option(s) changes due to user
|
|
69
|
+
- interaction with the select element.
|
|
70
|
+
- @param {string=} ngOptions sets the options that the select is populated with and defines what is
|
|
71
|
+
- set on the model on selection. See {@link ngOptions `ngOptions`}.
|
|
72
|
+
- @param {string=} ngAttrSize sets the size of the select element dynamically. Uses the
|
|
73
|
+
- {@link guide/interpolation#-ngattr-for-binding-to-arbitrary-attributes ngAttr} directive.
|
|
74
|
+
- \*/
|
|
@@ -1,119 +1,12 @@
|
|
|
1
1
|
const NG_HIDE_CLASS = "ng-hide";
|
|
2
2
|
const NG_HIDE_IN_PROGRESS_CLASS = "ng-hide-animate";
|
|
3
|
-
/**
|
|
4
|
-
* @ngdoc directive
|
|
5
|
-
* @name ngShow
|
|
6
|
-
* @multiElement
|
|
7
|
-
*
|
|
8
|
-
* @description
|
|
9
|
-
* The `ngShow` directive shows or hides the given HTML element based on the expression provided to
|
|
10
|
-
* the `ngShow` attribute.
|
|
11
|
-
*
|
|
12
|
-
* The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
|
|
13
|
-
* The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
|
|
14
|
-
* `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
|
|
15
|
-
* {@link ng.directive:ngCsp ngCsp}).
|
|
16
|
-
*
|
|
17
|
-
* ```html
|
|
18
|
-
* <!-- when $scope.myValue is truthy (element is visible) -->
|
|
19
|
-
* <div ng-show="myValue"></div>
|
|
20
|
-
*
|
|
21
|
-
* <!-- when $scope.myValue is falsy (element is hidden) -->
|
|
22
|
-
* <div ng-show="myValue" class="ng-hide"></div>
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* When the `ngShow` expression evaluates to a falsy value then the `.ng-hide` CSS class is added
|
|
26
|
-
* to the class attribute on the element causing it to become hidden. When truthy, the `.ng-hide`
|
|
27
|
-
* CSS class is removed from the element causing the element not to appear hidden.
|
|
28
|
-
*
|
|
29
|
-
* ## Why is `!important` used?
|
|
30
|
-
*
|
|
31
|
-
* You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
|
|
32
|
-
* `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
|
|
33
|
-
* simple as changing the display style on a HTML list item would make hidden elements appear
|
|
34
|
-
* visible. This also becomes a bigger issue when dealing with CSS frameworks.
|
|
35
|
-
*
|
|
36
|
-
* By using `!important`, the show and hide behavior will work as expected despite any clash between
|
|
37
|
-
* CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
|
|
38
|
-
* developer chooses to override the styling to change how to hide an element then it is just a
|
|
39
|
-
* matter of using `!important` in their own CSS code.
|
|
40
|
-
*
|
|
41
|
-
* ### Overriding `.ng-hide`
|
|
42
|
-
*
|
|
43
|
-
* By default, the `.ng-hide` class will style the element with `display: none !important`. If you
|
|
44
|
-
* wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
|
|
45
|
-
* the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
|
|
46
|
-
* `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
|
|
47
|
-
*
|
|
48
|
-
* ```css
|
|
49
|
-
* .ng-hide:not(.ng-hide-animate) {
|
|
50
|
-
* /* These are just alternative ways of hiding an element */
|
|
51
|
-
* display: block!important;
|
|
52
|
-
* position: absolute;
|
|
53
|
-
* top: -9999px;
|
|
54
|
-
* left: -9999px;
|
|
55
|
-
* }
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* By default you don't need to override anything in CSS and the animations will work around the
|
|
59
|
-
* display style.
|
|
60
|
-
*
|
|
61
|
-
* @animations
|
|
62
|
-
* | Animation | Occurs |
|
|
63
|
-
* |-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
|
|
64
|
-
* | {@link $animate#addClass addClass} `.ng-hide` | After the `ngShow` expression evaluates to a non truthy value and just before the contents are set to hidden. |
|
|
65
|
-
* | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngShow` expression evaluates to a truthy value and just before contents are set to visible. |
|
|
66
|
-
*
|
|
67
|
-
* Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
|
|
68
|
-
* directive expression is true and false. This system works like the animation system present with
|
|
69
|
-
* `ngClass` except that you must also include the `!important` flag to override the display
|
|
70
|
-
* property so that the elements are not actually hidden during the animation.
|
|
71
|
-
*
|
|
72
|
-
* ```css
|
|
73
|
-
* /* A working example can be found at the bottom of this page. */
|
|
74
|
-
* .my-element.ng-hide-add, .my-element.ng-hide-remove {
|
|
75
|
-
* transition: all 0.5s linear;
|
|
76
|
-
* }
|
|
77
|
-
*
|
|
78
|
-
* .my-element.ng-hide-add { ... }
|
|
79
|
-
* .my-element.ng-hide-add.ng-hide-add-active { ... }
|
|
80
|
-
* .my-element.ng-hide-remove { ... }
|
|
81
|
-
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
|
|
85
|
-
* to block during animation states - ngAnimate will automatically handle the style toggling for you.
|
|
86
|
-
*
|
|
87
|
-
* @element ANY
|
|
88
|
-
* @param {string} ngShow If the {@link guide/expression expression} is truthy/falsy then the
|
|
89
|
-
* element is shown/hidden respectively.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* A simple example, animating the element's opacity:
|
|
93
3
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
* @
|
|
97
|
-
*
|
|
98
|
-
* ### Flickering when using ngShow to toggle between elements
|
|
99
|
-
*
|
|
100
|
-
* When using {@link ngShow} and / or {@link ngHide} to toggle between elements, it can
|
|
101
|
-
* happen that both the element to show and the element to hide are visible for a very short time.
|
|
102
|
-
*
|
|
103
|
-
* This usually happens when the {@link ngAnimate ngAnimate module} is included, but no actual animations
|
|
104
|
-
* are defined for {@link ngShow} / {@link ngHide}.
|
|
105
|
-
*
|
|
106
|
-
* There are several way to mitigate this problem:
|
|
107
|
-
*
|
|
108
|
-
* - {@link guide/animations#how-to-selectively-enable-disable-and-skip-animations Disable animations on the affected elements}.
|
|
109
|
-
* - Use {@link ngIf} or {@link ngSwitch} instead of {@link ngShow} / {@link ngHide}.
|
|
110
|
-
* - Use the special CSS selector `ng-hide.ng-hide-animate` to set `{display: none}` or similar on the affected elements.
|
|
111
|
-
* - Use `ng-class="{'ng-hide': expression}` instead of instead of {@link ngShow} / {@link ngHide}.
|
|
112
|
-
* - Define an animation on the affected elements.
|
|
4
|
+
ngShowDirective.$inject = ["$animate"];
|
|
5
|
+
/**
|
|
6
|
+
* @returns {import('../../types').Directive}
|
|
113
7
|
*/
|
|
114
|
-
export
|
|
115
|
-
|
|
116
|
-
($animate) => ({
|
|
8
|
+
export function ngShowDirective($animate) {
|
|
9
|
+
return {
|
|
117
10
|
restrict: "A",
|
|
118
11
|
multiElement: true,
|
|
119
12
|
link(scope, element, attr) {
|
|
@@ -127,119 +20,15 @@ export const ngShowDirective = [
|
|
|
127
20
|
});
|
|
128
21
|
});
|
|
129
22
|
},
|
|
130
|
-
}
|
|
131
|
-
|
|
23
|
+
};
|
|
24
|
+
}
|
|
132
25
|
|
|
26
|
+
ngHideDirective.$inject = ["$animate"];
|
|
133
27
|
/**
|
|
134
|
-
* @
|
|
135
|
-
* @name ngHide
|
|
136
|
-
* @multiElement
|
|
137
|
-
*
|
|
138
|
-
* @description
|
|
139
|
-
* The `ngHide` directive shows or hides the given HTML element based on the expression provided to
|
|
140
|
-
* the `ngHide` attribute.
|
|
141
|
-
*
|
|
142
|
-
* The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
|
|
143
|
-
* The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
|
|
144
|
-
* `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
|
|
145
|
-
* {@link ng.directive:ngCsp ngCsp}).
|
|
146
|
-
*
|
|
147
|
-
* ```html
|
|
148
|
-
* <!-- when $scope.myValue is truthy (element is hidden) -->
|
|
149
|
-
* <div ng-hide="myValue" class="ng-hide"></div>
|
|
150
|
-
*
|
|
151
|
-
* <!-- when $scope.myValue is falsy (element is visible) -->
|
|
152
|
-
* <div ng-hide="myValue"></div>
|
|
153
|
-
* ```
|
|
154
|
-
*
|
|
155
|
-
* When the `ngHide` expression evaluates to a truthy value then the `.ng-hide` CSS class is added
|
|
156
|
-
* to the class attribute on the element causing it to become hidden. When falsy, the `.ng-hide`
|
|
157
|
-
* CSS class is removed from the element causing the element not to appear hidden.
|
|
158
|
-
*
|
|
159
|
-
* ## Why is `!important` used?
|
|
160
|
-
*
|
|
161
|
-
* You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
|
|
162
|
-
* `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
|
|
163
|
-
* simple as changing the display style on a HTML list item would make hidden elements appear
|
|
164
|
-
* visible. This also becomes a bigger issue when dealing with CSS frameworks.
|
|
165
|
-
*
|
|
166
|
-
* By using `!important`, the show and hide behavior will work as expected despite any clash between
|
|
167
|
-
* CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
|
|
168
|
-
* developer chooses to override the styling to change how to hide an element then it is just a
|
|
169
|
-
* matter of using `!important` in their own CSS code.
|
|
170
|
-
*
|
|
171
|
-
* ### Overriding `.ng-hide`
|
|
172
|
-
*
|
|
173
|
-
* By default, the `.ng-hide` class will style the element with `display: none !important`. If you
|
|
174
|
-
* wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
|
|
175
|
-
* the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
|
|
176
|
-
* `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
|
|
177
|
-
*
|
|
178
|
-
* ```css
|
|
179
|
-
* .ng-hide:not(.ng-hide-animate) {
|
|
180
|
-
* /* These are just alternative ways of hiding an element */
|
|
181
|
-
* display: block!important;
|
|
182
|
-
* position: absolute;
|
|
183
|
-
* top: -9999px;
|
|
184
|
-
* left: -9999px;
|
|
185
|
-
* }
|
|
186
|
-
* ```
|
|
187
|
-
*
|
|
188
|
-
* By default you don't need to override in CSS anything and the animations will work around the
|
|
189
|
-
* display style.
|
|
190
|
-
*
|
|
191
|
-
* @animations
|
|
192
|
-
* | Animation | Occurs |
|
|
193
|
-
* |-----------------------------------------------------|------------------------------------------------------------------------------------------------------------|
|
|
194
|
-
* | {@link $animate#addClass addClass} `.ng-hide` | After the `ngHide` expression evaluates to a truthy value and just before the contents are set to hidden. |
|
|
195
|
-
* | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngHide` expression evaluates to a non truthy value and just before contents are set to visible. |
|
|
196
|
-
*
|
|
197
|
-
* Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
|
|
198
|
-
* directive expression is true and false. This system works like the animation system present with
|
|
199
|
-
* `ngClass` except that you must also include the `!important` flag to override the display
|
|
200
|
-
* property so that the elements are not actually hidden during the animation.
|
|
201
|
-
*
|
|
202
|
-
* ```css
|
|
203
|
-
* /* A working example can be found at the bottom of this page. */
|
|
204
|
-
* .my-element.ng-hide-add, .my-element.ng-hide-remove {
|
|
205
|
-
* transition: all 0.5s linear;
|
|
206
|
-
* }
|
|
207
|
-
*
|
|
208
|
-
* .my-element.ng-hide-add { ... }
|
|
209
|
-
* .my-element.ng-hide-add.ng-hide-add-active { ... }
|
|
210
|
-
* .my-element.ng-hide-remove { ... }
|
|
211
|
-
* .my-element.ng-hide-remove.ng-hide-remove-active { ... }
|
|
212
|
-
* ```
|
|
213
|
-
*
|
|
214
|
-
* Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
|
|
215
|
-
* to block during animation states - ngAnimate will automatically handle the style toggling for you.
|
|
216
|
-
*
|
|
217
|
-
* @element ANY
|
|
218
|
-
* @param {string} ngHide If the {@link guide/expression expression} is truthy/falsy then the
|
|
219
|
-
* element is hidden/shown respectively.
|
|
220
|
-
*
|
|
221
|
-
* @knownIssue
|
|
222
|
-
*
|
|
223
|
-
* ### Flickering when using ngHide to toggle between elements
|
|
224
|
-
*
|
|
225
|
-
* When using {@link ngShow} and / or {@link ngHide} to toggle between elements, it can
|
|
226
|
-
* happen that both the element to show and the element to hide are visible for a very short time.
|
|
227
|
-
*
|
|
228
|
-
* This usually happens when the {@link ngAnimate ngAnimate module} is included, but no actual animations
|
|
229
|
-
* are defined for {@link ngShow} / {@link ngHide}. Internet Explorer is affected more often than
|
|
230
|
-
* other browsers.
|
|
231
|
-
*
|
|
232
|
-
* There are several way to mitigate this problem:
|
|
233
|
-
*
|
|
234
|
-
* - {@link guide/animations#how-to-selectively-enable-disable-and-skip-animations Disable animations on the affected elements}.
|
|
235
|
-
* - Use {@link ngIf} or {@link ngSwitch} instead of {@link ngShow} / {@link ngHide}.
|
|
236
|
-
* - Use the special CSS selector `ng-hide.ng-hide-animate` to set `{display: none}` or similar on the affected elements.
|
|
237
|
-
* - Use `ng-class="{'ng-hide': expression}` instead of instead of {@link ngShow} / {@link ngHide}.
|
|
238
|
-
* - Define an animation on the affected elements.
|
|
28
|
+
* @returns {import('../../types').Directive}
|
|
239
29
|
*/
|
|
240
|
-
export
|
|
241
|
-
|
|
242
|
-
($animate) => ({
|
|
30
|
+
export function ngHideDirective($animate) {
|
|
31
|
+
return {
|
|
243
32
|
restrict: "A",
|
|
244
33
|
multiElement: true,
|
|
245
34
|
link(scope, element, attr) {
|
|
@@ -251,5 +40,5 @@ export const ngHideDirective = [
|
|
|
251
40
|
});
|
|
252
41
|
});
|
|
253
42
|
},
|
|
254
|
-
}
|
|
255
|
-
|
|
43
|
+
};
|
|
44
|
+
}
|