From 3961af4fea433e031a206732921c1a34bdbbe93f Mon Sep 17 00:00:00 2001 From: Zhicheng Wang Date: Fri, 31 Aug 2018 16:28:42 +0800 Subject: [PATCH] =?UTF-8?q?docs(API):=20=E7=BF=BB=E8=AF=91=20NgClass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aio/content/translations/cn/api-plan.md | 2 +- packages/common/src/directives/ng_class.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/aio/content/translations/cn/api-plan.md b/aio/content/translations/cn/api-plan.md index eb2dd24ace..5c0e9f6ebe 100644 --- a/aio/content/translations/cn/api-plan.md +++ b/aio/content/translations/cn/api-plan.md @@ -12,7 +12,7 @@ [x] |core/NgModule | 4,097 | 1.27 [x] |router/Router | 4,049 | 1.26 [ ] |animations/animate | 3,817 | 1.19 -[ ] |common/NgClass | 3,715 | 1.15 +[x] |common/NgClass | 3,715 | 1.15 [ ] |common/DatePipe | 3,576 | 1.11 [ ] |forms/FormsModule | 3,381 | 1.05 [x] |core/Input | 3,354 | 1.04 diff --git a/packages/common/src/directives/ng_class.ts b/packages/common/src/directives/ng_class.ts index a8260a7f5d..a83a55f1bd 100644 --- a/packages/common/src/directives/ng_class.ts +++ b/packages/common/src/directives/ng_class.ts @@ -28,12 +28,24 @@ import {Directive, DoCheck, ElementRef, Input, IterableChanges, IterableDiffer, * * Adds and removes CSS classes on an HTML element. * + * 从 HTML 元素上添加和移除 CSS 类。 + * * The CSS classes are updated as follows, depending on the type of the expression evaluation: + * + * CSS 类会根据表达式求值结果进行更新,更新逻辑取决于结果的类型: + * * - `string` - the CSS classes listed in the string (space delimited) are added, + * + * `string` - 会把列在字符串中的 CSS 类(空格分隔)添加进来, + * * - `Array` - the CSS classes declared as Array elements are added, + * + * `Array` - 会把数组中的各个元素作为 CSS 类添加进来, + * * - `Object` - keys are CSS classes that get added when the expression given in the value * evaluates to a truthy value, otherwise they are removed. * + * `Object` - 每个 key 都是要处理的 CSS 类,当表达式求值为真的时候则添加,为假则移除。 * */ @Directive({selector: '[ngClass]'})