Skip to content

Commit f42e633

Browse files
committed
feat(forms): added support for textarea
1 parent 81312e4 commit f42e633

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

modules/angular2/src/dom/browser_adapter.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
8383
void setText(Node el, String value) {
8484
el.text = value;
8585
}
86-
String getValue(InputElement el) => el.value;
87-
void setValue(InputElement el, String value) {
86+
String getValue(el) => el.value;
87+
void setValue(el, String value) {
8888
el.value = value;
8989
}
9090
bool getChecked(InputElement el) => el.checked;

modules/angular2/src/forms/directives.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export class ControlDirective {
7777
constructor(@Ancestor() groupDirective:ControlGroupDirective, el:NgElement) {
7878
this._groupDirective = groupDirective;
7979
this._el = el;
80+
this.controlName = null;
81+
this.type = null;
8082
this.validator = validators.nullValidator;
8183
}
8284

modules/angular2/test/forms/integration_spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,25 @@ export function main() {
174174
});
175175
}));
176176

177+
it("should support textarea", inject([AsyncTestCompleter], (async) => {
178+
var ctx = new MyComp(new ControlGroup({"text": new Control('old')}));
179+
180+
var t = `<div [control-group]="form">
181+
<textarea control="text"></textarea>
182+
</div>`;
183+
184+
compile(MyComp, t, ctx, (view) => {
185+
var textarea = queryView(view, "textarea")
186+
expect(textarea.value).toEqual("old");
187+
188+
textarea.value = "new";
189+
dispatchEvent(textarea, "change");
190+
191+
expect(ctx.form.value).toEqual({"text" : 'new'});
192+
async.done();
193+
});
194+
}));
195+
177196
it("should support custom value accessors", inject([AsyncTestCompleter], (async) => {
178197
var ctx = new MyComp(new ControlGroup({"name": new Control("aa")}));
179198

0 commit comments

Comments
 (0)