feat(forms): added support for textarea
This commit is contained in:
parent
81312e4b3e
commit
f42e6337b7
|
@ -83,8 +83,8 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||||
void setText(Node el, String value) {
|
void setText(Node el, String value) {
|
||||||
el.text = value;
|
el.text = value;
|
||||||
}
|
}
|
||||||
String getValue(InputElement el) => el.value;
|
String getValue(el) => el.value;
|
||||||
void setValue(InputElement el, String value) {
|
void setValue(el, String value) {
|
||||||
el.value = value;
|
el.value = value;
|
||||||
}
|
}
|
||||||
bool getChecked(InputElement el) => el.checked;
|
bool getChecked(InputElement el) => el.checked;
|
||||||
|
|
|
@ -77,6 +77,8 @@ export class ControlDirective {
|
||||||
constructor(@Ancestor() groupDirective:ControlGroupDirective, el:NgElement) {
|
constructor(@Ancestor() groupDirective:ControlGroupDirective, el:NgElement) {
|
||||||
this._groupDirective = groupDirective;
|
this._groupDirective = groupDirective;
|
||||||
this._el = el;
|
this._el = el;
|
||||||
|
this.controlName = null;
|
||||||
|
this.type = null;
|
||||||
this.validator = validators.nullValidator;
|
this.validator = validators.nullValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 = `<div [control-group]="form">
|
||||||
|
<textarea control="text"></textarea>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
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) => {
|
it("should support custom value accessors", inject([AsyncTestCompleter], (async) => {
|
||||||
var ctx = new MyComp(new ControlGroup({"name": new Control("aa")}));
|
var ctx = new MyComp(new ControlGroup({"name": new Control("aa")}));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue