Angular 2警报仅显示一次

时间:2017-02-15 15:57:00

标签: angular ng2-bootstrap

我有一个有角度的2忘记密码组件。该组件要求服务器生成SMS验证码,并在发送SMS消息时提醒用户。 收到服务响应后,会显示一条警告,提示您使用*ngIf将代码发送到用户的手机。

但是,当用户要求提供第二个代码时,警报(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>

1 个答案:

答案 0 :(得分:1)

在对话框解除后,您应该将exec重置为false。我希望activeVerificationCodeSent被解雇,但你不会重置状态。您应该在模板中执行以下操作:

<alert>

<div *ngIf="activeVerificationCodeSent">** <alert type="danger" [dismissible]="true" (onClose)="onAlertClose()"> <strong>Bilgi</strong> Doğrulama Kodu telefonunuza gonderildi. </alert> </div> 中添加一项功能:

ForgotPasswordComponent