我有一张表格
<form #f="ngForm" novalidate (ngSubmit)="changePassword(f)">
<ion-item>
<ion-input type="password" placeholder="Current Password" name="currentPassword" [(ngModel)]="user.currentPassword"></ion-input>
</ion-item>
<ion-item>
<ion-input type="password" name="newPassword" placeholder="New Password" [(ngModel)]="user.newPassword" required validateEqual="confirmPassword" reverse="true" #newPassword="ngModel"></ion-input>
</ion-item>
<ion-item [hidden]="newPassword.valid || (newPassword.pristine && !f.submitted)" class="validation_error">
<ion-label class="text-danger">
New Password is required
</ion-label>
</ion-item>
<ion-item>
<ion-input type="password" name="confirmPassword" placeholder="Confrim Password" [(ngModel)]="user.confirmPassword" required validateEqual="newPassword" reverse="false" #confirmPassword="ngModel"></ion-input>
</ion-item>
<ion-item [hidden]="confirmPassword.valid || (confirmPassword.pristine && !f.submitted)" class="validation_error">
<ion-label class="text-danger">
Password mismatch
</ion-label>
</ion-item>
<div class="space_lr">
<button block ion-button>Done</button>
</div>
<!-- /.space_lr -->
</form>
我需要获取当前密码和新密码的值。
我正在尝试的方法是返回一个没有错误的空白,我非常好奇。
我有一个名为
的功能 account = {
currentPassword: '',
newPassword: '',
};
changePassword() {
let loading = this.loadingCtrl.create({
content: 'Please wait...'
});
let callParams = {
lmId: this.lmService.getSession('memberId'),
currentPassword: this.account.currentPassword,
newPassword: this.account.newPassword
}
console.log(this.account.newPassword) // returns blank
.........
知道我做错了吗?
答案 0 :(得分:0)
正如评论中所建议的那样:
您在模板中使用user.newPassword
代替account.newPassword
作为ngModel
。