fix(text-input): change to after content checked to get the value

references #710
This commit is contained in:
Brandy Carney
2015-12-17 19:26:02 -05:00
parent 7c1b89f369
commit 24c3b3d787
3 changed files with 42 additions and 20 deletions

View File

@ -16,11 +16,16 @@ class E2EApp {
this.login = {};
this.user = {
username: 'asdf',
password: '82'
};
this.submitted = false;
}
submit(ev) {
console.log("Submitted", this.loginForm.value);
submit(ev, value) {
console.log("Submitted", value);
this.submitted = true;
}

View File

@ -4,7 +4,7 @@
<ion-content>
<form (ng-submit)="submit($event)" [ngFormModel]="loginForm" #mf="ngForm" novalidate>
<form [ngFormModel]="loginForm" #mf="ngForm" novalidate>
<ion-list>
<ion-input>
@ -36,16 +36,10 @@
<textarea [(ngModel)]="login.comments" ngControl="comments" placeholder="Required" required>Comment value</textarea>
</ion-input>
<ion-item [hidden]="submitted == false || mf.form.valid">
<p danger>Form is Invalid</p>
</ion-item>
</ion-list>
<div padding>
<button block type="submit">Login</button>
<div padding-left padding-right>
<button block (click)="submit($event, login)">Login</button>
</div>
<div [hidden]="submitted == false" padding-left>
<div padding-left>
<b>Valid form?:</b> {{ mf.form.valid }}<br>
<b>Submitted form?:</b> {{ submitted }}<br>
<b>Email:</b> {{ login.email }}<br>
@ -53,7 +47,29 @@
<b>Password:</b> {{ login.password }}<br>
<b>Comments:</b> {{ login.comments }}
</div>
</ion-list>
</form>
<form (ngSubmit)="submit($event, user)" #lf="ngForm">
<ion-list>
<ion-input floating-label>
<ion-label>Username</ion-label>
<input type="text" [(ngModel)]="user.username" ngControl="username" required>
</ion-input>
<ion-input floating-label>
<ion-label>Password</ion-label>
<input type="password" [(ngModel)]="user.password" ngControl="password" required>
</ion-input>
<div padding-left padding-right>
<button block type="submit">Login</button>
</div>
<div padding-left>
<b>Valid form?:</b> {{ lf.form.valid }}<br>
<b>Submitted form?:</b> {{ submitted }}<br>
<b>Username:</b> {{ user.username }}<br>
<b>Password:</b> {{ user.password }}<br>
</div>
</ion-list>
</form>
</ion-content>

View File

@ -490,7 +490,8 @@ export class TextInputElement {
if (ngControl) this.ngControl = ngControl;
}
ngOnInit() {
ngAfterContentChecked() {
console.log("Value", this.ngControl.value);
if (this.ngControl) this.value = this.ngControl.value;
this.wrapper && this.wrapper.hasValue(this.value);
}