2
我有一個角2忘記密碼組件。該組件要求服務器生成SMS驗證碼並在發送SMS消息時提醒用戶。 收到服務響應後,會顯示一條提示,說明使用*ngIf
將代碼交付給用戶的手機。Angular 2警報只顯示一次
但是,當用戶要求第二個代碼時,不會彈出警報(ng2-bootstrap)。
任何幫助表示感謝。
@Component({
templateUrl:'forgot-password.component.html',
styleUrls:['../../res/styles/login.component.css'],
providers:[{provide:AlertConfig, useFactory:getAlertConfig}]
})
export class ForgotPasswordComponent implements OnInit{
model:any={};
returnUrl:string;
smsCodeResponse:SMSVerificationInfo;
errorMessage:string;
activeVerificationCodeSent:boolean;
constructor(
private route:ActivatedRoute,
private router:Router,
private authenticationService:AuthenticationService
){}
requestVerificationCode(){
this.authenticationService.requestSMSCode(this.model.username)
.subscribe(
(s)=>this.smsCodeResponse=s,
(e)=>this.errorMessage=e,
()=> {
this.activeVerificationCodeSent=this.smsCodeResponse.aktifmi)
};
}
}
模板
<div *ngIf="activeVerificationCodeSent">
<alert type="danger" dismissible="true">
<strong>Bilgi</strong> Doğrulama Kodu telefonunuza gonderildi.
</alert>
</div>
,使之成爲可讀請格式化你的代碼... – bergben
@bergben這是一個刺在我的眼中:D – PierreDuc