5
我是新來的角2如何使用Angular 2在單個ts文件中編寫2個表單驗證?
我們在與獨立的div標籤,每當1 div
執行HTML 2點的形式,第二div
是假的狀態。每當成功回撥第二個div
將成爲真實狀態。每當它到達第二個div
真實狀態它將顯示this error message。
下面是我的.ts文件代碼:
constructor(public navCtrl: NavController,
public navParams: NavParams,
public formBuilder:FormBuilder,
public logger: Logger,
public rest: Rest
) {
this.customer_id=this.navParams.get('customer_id');
this.mobile=this.navParams.get('mobile');
this.myForm = formBuilder.group({
'otpNumber': ['', Validators.required]
//'password': ['', Validators.required]
});
this.myForm1 = formBuilder.group({
'newpassword': ['', Validators.required],
'conformPassword': ['', Validators.required]
});
this.getotp();
}
submit(){
let validateOTPObj = {
loginId: this.mobile,
otp:this.myForm.value.otpNumber
}
this.logger.debug("checking the otpNumber"+JSON.stringify(validateOTPObj));
this.rest.post('/validateOTP' ,validateOTPObj)
.subscribe((result)=>{
this.logger.debug("checking data of success " + JSON.stringify(result));
if(result.status=='1'){
//this.navCtrl.push(,{});
//this.access_token = id;
this.firstDiv=false;
this.secondDiv = true;
this.logger.debug("checking access tocken "+ this.access_token);
alert("otp success");
} else {
this.logger.info("error");
}
});
}
可以共享HTML的一面呢? –
它會更好,如果你分享你的HTML,但基於錯誤消息,也許你只是忘了在html中聲明myForm/myForm1 formGroup [formGroup] =「myForm」[formGroup] =「myForm1」' –