1 |
49598
|
stefanos.g
|
/**
|
2 |
|
|
* @license
|
3 |
|
|
* Copyright Google Inc. All Rights Reserved.
|
4 |
|
|
*
|
5 |
|
|
* Use of this source code is governed by an MIT-style license that can be
|
6 |
|
|
* found in the LICENSE file at https://angular.io/license
|
7 |
|
|
*/
|
8 |
|
|
import { DoCheck, ElementRef, IterableDiffers, KeyValueDiffers, Renderer } from '@angular/core';
|
9 |
|
|
/**
|
10 |
|
|
* @ngModule CommonModule
|
11 |
|
|
*
|
12 |
|
|
* @whatItDoes Adds and removes CSS classes on an HTML element.
|
13 |
|
|
*
|
14 |
|
|
* @howToUse
|
15 |
|
|
* ```
|
16 |
|
|
* <some-element [ngClass]="'first second'">...</some-element>
|
17 |
|
|
*
|
18 |
|
|
* <some-element [ngClass]="['first', 'second']">...</some-element>
|
19 |
|
|
*
|
20 |
|
|
* <some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
|
21 |
|
|
*
|
22 |
|
|
* <some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
|
23 |
|
|
*
|
24 |
|
|
* <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
|
25 |
|
|
* ```
|
26 |
|
|
*
|
27 |
|
|
* @description
|
28 |
|
|
*
|
29 |
|
|
* The CSS classes are updated as follows, depending on the type of the expression evaluation:
|
30 |
|
|
* - `string` - the CSS classes listed in the string (space delimited) are added,
|
31 |
|
|
* - `Array` - the CSS classes declared as Array elements are added,
|
32 |
|
|
* - `Object` - keys are CSS classes that get added when the expression given in the value
|
33 |
|
|
* evaluates to a truthy value, otherwise they are removed.
|
34 |
|
|
*
|
35 |
|
|
* @stable
|
36 |
|
|
*/
|
37 |
|
|
export declare class NgClass implements DoCheck {
|
38 |
|
|
private _iterableDiffers;
|
39 |
|
|
private _keyValueDiffers;
|
40 |
|
|
private _ngEl;
|
41 |
|
|
private _renderer;
|
42 |
|
|
private _iterableDiffer;
|
43 |
|
|
private _keyValueDiffer;
|
44 |
|
|
private _initialClasses;
|
45 |
|
|
private _rawClass;
|
46 |
|
|
constructor(_iterableDiffers: IterableDiffers, _keyValueDiffers: KeyValueDiffers, _ngEl: ElementRef, _renderer: Renderer);
|
47 |
|
|
klass: string;
|
48 |
|
|
ngClass: string | string[] | Set<string> | {
|
49 |
|
|
[klass: string]: any;
|
50 |
|
|
};
|
51 |
|
|
ngDoCheck(): void;
|
52 |
|
|
private _cleanupClasses(rawClassVal);
|
53 |
|
|
private _applyKeyValueChanges(changes);
|
54 |
|
|
private _applyIterableChanges(changes);
|
55 |
|
|
private _applyInitialClasses(isCleanup);
|
56 |
|
|
private _applyClasses(rawClassVal, isCleanup);
|
57 |
|
|
private _toggleClass(klass, enabled);
|
58 |
|
|
}
|