fix(text-input): only update input-has-value onInit

This commit is contained in:
Tim Lancina
2015-12-17 19:04:41 -06:00
parent c20191eb88
commit 77697246e5

View File

@ -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,10 @@ 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;
this.wrapper && this.wrapper.hasValue(this.value);
ngOnInit(){
this.wrapper && this.wrapper.hasValue(this.ngModel);
}
focusChange(changed) {