From cbfc925191f7374ad29df4466aa2afe1c7e87b26 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 17 Dec 2015 19:11:21 -0600 Subject: [PATCH] Revert "fix(text-input): only update input-has-value onInit" This reverts commit 77697246e5071a7d31d6782eddc44da7283072c9. --- ionic/components/text-input/text-input.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ionic/components/text-input/text-input.ts b/ionic/components/text-input/text-input.ts index 679ec9d1fd..c116534eb6 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} from 'angular2/common'; +import {NgIf, NgControl} 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', 'ngModel'], + inputs: ['value'], host: { '(focus)': 'focusChange(true)', '(blur)': 'focusChange(false)', @@ -471,6 +471,7 @@ export class TextInputElement { elementRef: ElementRef, renderer: Renderer, @Optional() wrapper: TextInput, + @Optional() ngControl: NgControl ) { this.type = type; this.elementRef = elementRef; @@ -486,10 +487,13 @@ export class TextInputElement { wrapper.registerInput(this); } + if (ngControl) this.ngControl = ngControl; } - ngOnInit(){ - this.wrapper && this.wrapper.hasValue(this.ngModel); + ngAfterContentChecked() { + if (this.ngControl) console.log("Value", this.ngControl.value); + if (this.ngControl) this.value = this.ngControl.value; + this.wrapper && this.wrapper.hasValue(this.value); } focusChange(changed) {