當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。