diff --git a/packages/forms/src/directives/ng_model.ts b/packages/forms/src/directives/ng_model.ts index 966bbe04b2..e46b59e367 100644 --- a/packages/forms/src/directives/ng_model.ts +++ b/packages/forms/src/directives/ng_model.ts @@ -29,6 +29,7 @@ export const formControlBinding: any = { /** * `ngModel` forces an additional change detection run when its inputs change: * E.g.: + *
当输入发生变化时,`ngModel` 会强制运行额外的变更检测,比如:
* ``` *根据领域对象创建一个 `FormControl` 实例,并把它绑定到一个表单控件元素上。
* * The `FormControl` instance will track the value, user interaction, and * validation status of the control and keep the view synced with the model. If used * within a parent form, the directive will also register itself with the form as a child * control. * + * 这个 `FormControl` 实例将会跟踪值、用户交互和控件的验证状态,以保持视图与模型的同步。 + * 如果用在某个父表单中,该指令还会把自己注册为这个父表单的子控件。 + * * This directive can be used by itself or as part of a larger form. All you need is the * `ngModel` selector to activate it. * + * 这个指令可以单独使用,也可以用作一个大表单的一部分。你所要做的一切就是用 `ngModel` 选择器来激活它。 + * * It accepts a domain model as an optional `Input`. If you have a one-way binding * to `ngModel` with `[]` syntax, changing the value of the domain model in the component * class will set the value in the view. If you have a two-way binding with `[()]` syntax * (also known as 'banana-box syntax'), the value in the UI will always be synced back to * the domain model in your class as well. * + * 它可以接受一个领域模型作为可选的 `Input`。如果使用 `[]` 语法来单向绑定到 `ngModel`,那么在组件类中修改领域模型将会更新视图中的值。 + * 如果使用 `[()]` 语法来双向绑定到 `ngModel`,那么视图中值的变化同样会随时同步回组件类中的领域模型。 + * * If you wish to inspect the properties of the associated `FormControl` (like * validity state), you can also export the directive into a local template variable using * `ngModel` as the key (ex: `#myVar="ngModel"`). You can then access the control using the @@ -72,33 +95,58 @@ const resolvedPromise = Promise.resolve(null); * will fall through to the control anyway, so you can access them directly. You can see a * full list of properties directly available in `AbstractControlDirective`. * + * 如果你希望查看与 `FormControl` 相关的属性(比如校验状态),你也可以使用 `ngModel` 作为键,把该指令导出到一个局部模板变量中(如:`#myVar="ngModel"`)。 + * 你也可以使用该指令的 `control` 属性来访问此控件,实际上你要用到的大多数属性(如 `valid` 和 `dirty`)都会委托给该控件,这样你就可以直接访问这些属性了。 + * 你可以在 `AbstractControlDirective` 中直接查看这些属性的完整列表。 + * * The following is an example of a simple standalone control using `ngModel`: * + * 下面是一个在简单的独立控件中使用 `ngModel` 的例子: + * * {@example forms/ts/simpleNgModel/simple_ng_model_example.ts region='Component'} * * When using the `ngModel` within `