From 9fe1b34c8f76b54ce0981270b87fe3c71765d9c3 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Fri, 18 Dec 2015 11:11:17 -0500 Subject: [PATCH] fix(text-input): fixed text input so it will work without ngControl. Updated tests. closes #710 --- .../text-input/test/form-inputs/index.ts | 5 ++- .../text-input/test/form-inputs/main.html | 33 +++++++------------ ionic/components/text-input/text-input.ts | 13 ++++---- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/ionic/components/text-input/test/form-inputs/index.ts b/ionic/components/text-input/test/form-inputs/index.ts index 213ba4d867..879c86f309 100644 --- a/ionic/components/text-input/test/form-inputs/index.ts +++ b/ionic/components/text-input/test/form-inputs/index.ts @@ -14,7 +14,10 @@ class E2EApp { comments: ["", Validators.required] }); - this.login = {}; + this.login = { + email: 'help@ionic.io', + username: 'admin' + }; this.user = { username: 'asdf', diff --git a/ionic/components/text-input/test/form-inputs/main.html b/ionic/components/text-input/test/form-inputs/main.html index f2314420a2..9dc613e003 100644 --- a/ionic/components/text-input/test/form-inputs/main.html +++ b/ionic/components/text-input/test/form-inputs/main.html @@ -7,33 +7,24 @@
- - Email: - - + + Email + - - Username: - - + + Username + - - Password: - - + + Password + - - Comments: - + + Comments +
diff --git a/ionic/components/text-input/text-input.ts b/ionic/components/text-input/text-input.ts index c116534eb6..f64ffb1218 100644 --- a/ionic/components/text-input/text-input.ts +++ b/ionic/components/text-input/text-input.ts @@ -1,5 +1,5 @@ import {Component, Directive, Attribute, forwardRef, Host, Optional, ElementRef, Renderer} from 'angular2/core'; -import {NgIf, NgControl} from 'angular2/common'; +import {NgIf} from 'angular2/common'; import {NavController} from '../nav/nav-controller'; import {Config} from '../../config/config'; @@ -457,7 +457,7 @@ export class TextInput { */ @Directive({ selector: 'textarea,input[type=text],input[type=password],input[type=number],input[type=search],input[type=email],input[type=url],input[type=tel],input[type=date],input[type=datetime],input[type=datetime-local],input[type=week],input[type=time]', - inputs: ['value'], + inputs: ['value', 'ngModel'], host: { '(focus)': 'focusChange(true)', '(blur)': 'focusChange(false)', @@ -471,7 +471,6 @@ export class TextInputElement { elementRef: ElementRef, renderer: Renderer, @Optional() wrapper: TextInput, - @Optional() ngControl: NgControl ) { this.type = type; this.elementRef = elementRef; @@ -487,13 +486,13 @@ export class TextInputElement { wrapper.registerInput(this); } - if (ngControl) this.ngControl = ngControl; } - ngAfterContentChecked() { - if (this.ngControl) console.log("Value", this.ngControl.value); - if (this.ngControl) this.value = this.ngControl.value; + ngOnInit() { + if (this.ngModel) console.log("Value", this.ngModel); + if (this.ngModel) this.value = this.ngModel; this.wrapper && this.wrapper.hasValue(this.value); + console.log(this.value); } focusChange(changed) {