Reputation: 21
please help me how can i pass my textbox values to typesccript
<div>
<input type="text" [(ngModel)]="Email" />
<input type="text" [(ngModel)]="Password" />
<input type="button" class="btn btn-success" value="Submit" (click)="Validation()" />
</div>
Student.ts
this is my class its having Email And password this call i used in studentController
export class Validationclass {
Email: string;
Password: string;
}
export class studentController {
public val: Validationclass;
Validation() {
if (this.val.Email != null && this.val.Password != null) {
alert('ok')
}
else
alert("Emptr");
}
Upvotes: 0
Views: 4447
Reputation: 854
You need to assign the ngModel to the correct vars in your controller like this:
<div>
<input type="text" [(ngModel)]="val.Email" />
<input type="text" [(ngModel)]="val.Password" />
<input type="button" class="btn btn-success" value="Submit" (click)="Validation()" />
</div>
Make sure in your controller to initialize the ValidationClass like this:
ngOnInit() {
val = new Validationclass();
}
Upvotes: 1