/** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { DoCheck, ElementRef, IterableDiffers, KeyValueDiffers, OnDestroy, Renderer } from '@angular/core'; /** * The `NgClass` directive conditionally adds and removes CSS classes on an HTML element based on * an expression's evaluation result. * * The result of an expression evaluation is interpreted differently depending on type of * the expression evaluation result: * - `string` - all the CSS classes listed in a string (space delimited) are added * - `Array` - all the CSS classes (Array elements) are added * - `Object` - each key corresponds to a CSS class name while values are interpreted as expressions * evaluating to `Boolean`. If a given expression evaluates to `true` a corresponding CSS class * is added - otherwise it is removed. * * While the `NgClass` directive can interpret expressions evaluating to `string`, `Array` * or `Object`, the `Object`-based version is the most often used and has an advantage of keeping * all the CSS class names in a template. * * ### Example ([live demo](http://plnkr.co/edit/a4YdtmWywhJ33uqfpPPn?p=preview)): * * ``` * import {Component} from '@angular/core'; * import {NgClass} from '@angular/common'; * * @Component({ * selector: 'toggle-button', * inputs: ['isDisabled'], * template: ` *
`, * styles: [` * .button { * width: 120px; * border: medium solid black; * } * * .active { * background-color: red; * } * * .disabled { * color: gray; * border: medium solid gray; * } * `], * directives: [NgClass] * }) * class ToggleButton { * isOn = false; * isDisabled = false; * * toggle(newState) { * if (!this.isDisabled) { * this.isOn = newState; * } * } * } * ``` * * @stable */ export declare class NgClass implements DoCheck, OnDestroy { private _iterableDiffers; private _keyValueDiffers; private _ngEl; private _renderer; private _iterableDiffer; private _keyValueDiffer; private _initialClasses; private _rawClass; constructor(_iterableDiffers: IterableDiffers, _keyValueDiffers: KeyValueDiffers, _ngEl: ElementRef, _renderer: Renderer); initialClasses: string; rawClass: string | string[] | Set