当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript angular2-flash-messages.FlashMessagesService类代码示例

本文整理汇总了TypeScript中angular2-flash-messages.FlashMessagesService的典型用法代码示例。如果您正苦于以下问题:TypeScript FlashMessagesService类的具体用法?TypeScript FlashMessagesService怎么用?TypeScript FlashMessagesService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FlashMessagesService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: onRegisterSubmit

  onRegisterSubmit() {
    if (!this.username || !this.password1 || !this.password2) {
      return this.flashMsg.show('Please fill out all fields', { cssClass: 'notification is-danger' });
    } else if (this.password1 !== this.password2) {
      this.password1 = '';
      this.password2 = '';
      return this.flashMsg.show('Passwords do not match', { cssClass: 'notification is-danger' });
    }
    this.username = this.username.trim();

    this.auth.register({ username: this.username, password: this.password1 })
      .subscribe(data => {
        // Registration denied
        if (!data.success) {
          if (data.status === 1) { // err
            return this.flashMsg.show(data.msg, { cssClass: 'notification is-danger' });
          } else if (data.status === 2) { // username already exists
            this.username = '';
            this.password1 = '';
            this.password2 = '';
            return this.flashMsg.show(data.msg, { cssClass: 'notification is-danger' });
          } else { // nothing
            return this.flashMsg.show(data.msg, { cssClass: 'notification is-danger' });
          }
        }
        // Registration allowed
        if (data.success) {
          return this.router.navigate(['login']);
        }
      })


  }
开发者ID:schoettkr,项目名称:nightlife-app,代码行数:33,代码来源:register.component.ts

示例2:

 this.authService.forgotPasswordUser({email: this.email}).subscribe(data => {
   if(data.success){
     this.flashMessage.show('An email has been sent to '+this.email+' with further instruction !', {cssClass: 'alert-success', timeout: 5000});
   } else {
     this.flashMessage.show(data.msg, {cssClass: 'alert-danger', timeout: 3000});
   }
 });
开发者ID:anhnktp,项目名称:mean-auth-realtime,代码行数:7,代码来源:forgot.component.ts

示例3: onRegisterSubmit

  onRegisterSubmit(){
  
    const user = {
      first_name: this.first_name,
      last_name: this.last_name,
      email: this.email,
      username: this.username,
      password: this.password
    }
    
    // Require Fields
    if(!this.validateService.validateRegister(user)){
      this.flashMessage.show('Ooops ... you forgot to fill all the fields', {cssClass: 'alert-warning text-center', timeout: 3000});
      return false;
    }
    // Validate Email
       if(!this.validateService.validateEmail(user.email)){
     this.flashMessage.show('Seems like the email you entered is wrong .. please provide a valid email address', {cssClass: 'alert-warning text-center', timeout: 3000})
      return false;
    }
    // Register User
    this.authService.registerUser(user).subscribe(data =>{
      if(data.success){
         this.flashMessage.show('you made it ! you are now registered with Dobble Social Network', {cssClass: 'alert-success text-center', timeout: 3000})
         this.router.navigate(['/login']);
      } else{
        this.flashMessage.show('Ooops .. something went wrong', {cssClass: 'alert-warning text-center', timeout: 3000})
         this.router.navigate(['/register']);
      }
    });
      

  }
开发者ID:KLTR,项目名称:Dobble-meanstack,代码行数:33,代码来源:register.component.ts

示例4: register

  register() {
    const user: User = new User(this.name, this.username, this.email, this.password);

    if (!this.validationService.validateRegister(user)) {
      console.log("fuck off")
      this.flashMessagesService.show("fuck off")
      return false;
    }

    if (!this.validationService.validateEmail(user.email)) {
      console.log("email fucked")
      this.flashMessagesService.show('email fucked', { cssClass: 'alert-danger', timeout: 3000 })
      return false;
    }

    console.log("sending " + user.email);
    this.authService.registerUser(user).subscribe(
      res => {
        this.flashMessagesService.show(res['message'] +". Please log in", { cssClass: 'alert-success', timeout: 10000 })
        this.router.navigateByUrl('/login');
      },
      error => {
        this.flashMessagesService.show("Unexpected error happened", { cssClass: 'alert-danger', timeout: 10000 })
        console.log(error)
        this.router.navigateByUrl("/register")
      }

    );

  }
开发者ID:Khasanboy,项目名称:pollingApp,代码行数:30,代码来源:register.component.ts

示例5: onRegisterSubmit

  onRegisterSubmit(){
    let user = {
      name: this.name,
      email: this.email,
      username: this.username,
      password: this.password
    }

    // Required Fields
    if(!this.validateService.validateRegister(user)){
      this.flashMessage.show('Please fill in all fields !', {cssClass: 'alert-danger', timeout: 3000});
      return false;
    }

    // Validate Email
    if(!this.validateService.validateEmail(user.email)){
      this.flashMessage.show('Please use a valid email !', {cssClass: 'alert-danger', timeout: 3000});
      return false;
    }

    if (this.password != this.password2) return false;

    // Register user
    this.authService.registerUser(user).subscribe(data => {
      if(data.success){
        this.flashMessage.show('You are now registered successfully and can log in !', {cssClass: 'alert-success', timeout: 3000});
        this.router.navigate(['/login']);
      } else {
        this.flashMessage.show(data.msg, {cssClass: 'alert-danger', timeout: 3000});
        this.router.navigate(['/register']);
      }
    });

  }
开发者ID:anhnktp,项目名称:mean-auth-realtime,代码行数:34,代码来源:register.component.ts

示例6:

 this._login.logout((err) => {
   if (err) {
     this._flashMessage.show(err.message, { cssClass: 'alert-danger', timeout: 5000 });
   } else {
     this._flashMessage.show('Bye!', { cssClass: 'alert-info', timeout: 5000 });
   }
 });
开发者ID:gabuladze,项目名称:vout,代码行数:7,代码来源:navbar.component.ts

示例7: onRegisterSubmit

  onRegisterSubmit() {
    const user = {
      name: this.name,
      username: this.username,
      email: this.email,
      password: this.password
    };

    //Required
    if (!this.validateService.validateRegister(user)) {
      this.flashMessagesService.show('fill in all fileds', { cssClass: 'alert-danger', timeout: 2000 });
      return false;
    }

    if (!this.validateService.validateEmail(user.email)) {
      this.flashMessagesService.show('worng email', { cssClass: 'alert-danger', timeout: 2000 });
      return false;
    }

    //Register User
    this.authService.registerUser(user).subscribe(data => {
      if (data.success) {
        this.flashMessagesService.show('Registered Success', { cssClass: 'alert-success', timeout: 2000 });
        this.router.navigate(['/login']);
      } else {
        this.flashMessagesService.show('Registered Failed', { cssClass: 'alert-danger', timeout: 2000 });
        this.router.navigate(['/register']);
      }
    });
  }
开发者ID:RicoLiu,项目名称:literate-telegram,代码行数:30,代码来源:register.component.ts

示例8: if

      .subscribe(data => {

        // Login denied
        if (!data.success) {
          if (data.status === 1) {
            this.flashMsg.show('Wrong username!', { cssClass: 'notification is-danger' });
          } else if (data.status === 2) {
            this.flashMsg.show('Wrong password!', { cssClass: 'notification is-danger' });
          } else {
            this.flashMsg.show(data.msg, { cssClass: 'notification is-danger' });
          }
          this.username = '';
          this.password = '';
          return;
        }

        // Login allowed
        if (data.success && data.status === 0) {
          this.auth.storeToken(data.token, data.user);
          return this.location.back();
        } else {
          this.flashMsg.show('Error', { cssClass: 'notification is-danger' });
        }

      });
开发者ID:schoettkr,项目名称:nightlife-app,代码行数:25,代码来源:login.component.ts

示例9:

 }).subscribe((d) => {
   if(d == 1) {
     this._fM.show('<h5>Thank you!</h5><p>We appreciate you contacting us about getting in touch.<br>One of our colleagues will get back to you shortly.</p>', { cssClass: 'alert-success', timeout: 6000 });
     this.contactForm.reset();
   } else {
     this._fM.show('Error please try again!', { cssClass: 'alert-danger', timeout: 3000 });
   }
 });
开发者ID:viveksh09876,项目名称:fruitastic,代码行数:8,代码来源:contact.component.ts

示例10:

 this._polls.createPoll(this.title, this.options, userId).subscribe(data => {
   if (data.success) {
     this._flashMessage.show('Poll has been added!', { cssClass: 'alert-success', timeout: 5000 });
     this.router.navigate(['/polls']);
   } else {
     this._flashMessage.show(data.message, { cssClass: 'alert-danger', timeout: 5000 });
   }
 });
开发者ID:gabuladze,项目名称:vout,代码行数:8,代码来源:create-poll.component.ts


注:本文中的angular2-flash-messages.FlashMessagesService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。