From f42e6337b712b07a54e6cc071ac3bfe649a35f79 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Thu, 19 Mar 2015 09:51:30 -0700 Subject: [PATCH] feat(forms): added support for textarea --- modules/angular2/src/dom/browser_adapter.dart | 4 ++-- modules/angular2/src/forms/directives.js | 2 ++ .../angular2/test/forms/integration_spec.js | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/modules/angular2/src/dom/browser_adapter.dart b/modules/angular2/src/dom/browser_adapter.dart index 6604f2517e..320ff28956 100644 --- a/modules/angular2/src/dom/browser_adapter.dart +++ b/modules/angular2/src/dom/browser_adapter.dart @@ -83,8 +83,8 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter { void setText(Node el, String value) { el.text = value; } - String getValue(InputElement el) => el.value; - void setValue(InputElement el, String value) { + String getValue(el) => el.value; + void setValue(el, String value) { el.value = value; } bool getChecked(InputElement el) => el.checked; diff --git a/modules/angular2/src/forms/directives.js b/modules/angular2/src/forms/directives.js index f217177466..ef13dcf55e 100644 --- a/modules/angular2/src/forms/directives.js +++ b/modules/angular2/src/forms/directives.js @@ -77,6 +77,8 @@ export class ControlDirective { constructor(@Ancestor() groupDirective:ControlGroupDirective, el:NgElement) { this._groupDirective = groupDirective; this._el = el; + this.controlName = null; + this.type = null; this.validator = validators.nullValidator; } diff --git a/modules/angular2/test/forms/integration_spec.js b/modules/angular2/test/forms/integration_spec.js index 066839fbe8..0c4575e341 100644 --- a/modules/angular2/test/forms/integration_spec.js +++ b/modules/angular2/test/forms/integration_spec.js @@ -174,6 +174,25 @@ export function main() { }); })); + it("should support textarea", inject([AsyncTestCompleter], (async) => { + var ctx = new MyComp(new ControlGroup({"text": new Control('old')})); + + var t = `
+ +
`; + + compile(MyComp, t, ctx, (view) => { + var textarea = queryView(view, "textarea") + expect(textarea.value).toEqual("old"); + + textarea.value = "new"; + dispatchEvent(textarea, "change"); + + expect(ctx.form.value).toEqual({"text" : 'new'}); + async.done(); + }); + })); + it("should support custom value accessors", inject([AsyncTestCompleter], (async) => { var ctx = new MyComp(new ControlGroup({"name": new Control("aa")}));