• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript material.MatSnackBar类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: canActivate

 canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
   if (this.userService.isRegistered()) {
     return true;
   }
   const config = new MatSnackBarConfig();
   config.duration = 1000;
   const snackBarRef = this.snackBar.open('You must fill both name fields before playing.', '', config);
   return false;
 }
开发者ID:snuroop,项目名称:ExploringAngular,代码行数:9,代码来源:is-registerd-guard.ts


示例2: showToast

 showToast(message: string, action = 'Close', config?: MatSnackBarConfig) {
   this.snackBar.open(
     message,
     action,
     config || {
       duration: 7000,
     }
   )
 }
开发者ID:Raju06,项目名称:Angular-6-for-Enterprise-Ready-Web-Applications,代码行数:9,代码来源:ui.service.ts


示例3: startUpload

    async startUpload(event: FileList) {

        const file = event.item(0);

        // Client-side validation: Must be an image and smaller than 10MB.
        if (file.type.split('/')[0] !== 'image') {
            return this.snackBar.open('Unsupported File Type', '', { duration: 3000, panelClass: 'snackbar-error' });
        }
        // Must be smaller than 20MB, http://www.unitconversion.org/data-storage/megabytes-to-bytes-conversion.html
        if (file.size > 10485760) {
            return this.snackBar.open('Images must be smaller than 10MB', '', { duration: 5000, panelClass: 'snackbar-error' });
        }

        const dictionary = await this.dictionariesService.getDictionary();

        // Replace spaces w/ underscores in dict name, remove special characters from lexeme so image converter can accept filename
        const _dictName = dictionary.name.replace(/\s+/g, '_');
        const _lexeme = this.entry.lx.replace(/[^a-z0-9+]+/gi, '_');
        const fileTypeSuffix = file.name.match(/\.[0-9a-z]+$/i)[0];

        const path = `images/${_dictName}_${dictionary.id}/${_lexeme}_${this.entry.id}_${new Date().getTime()}${fileTypeSuffix}`;

        // optional metadata
        const { displayName, uid } = await this.auth.getUser();
        const customMetadata = { uploadedBy: displayName };

        this.task = this.storage.upload(path, file, { customMetadata });
        this.percentage = this.task.percentageChanges();
        this.task.then(snap => {
            if (snap.state === 'success') { this.savePhoto(path, displayName, uid, this.entry.lx, dictionary.id); }
        }).catch(() => {
            this.snackBar.open('Image Upload Failed', '', { duration: 3000, panelClass: 'snackbar-error' });
        });
    }
开发者ID:jacobbowdoin,项目名称:RapidWords,代码行数:34,代码来源:photo-upload.component.ts


示例4:

 const result = this.betterdb.createUser(details).subscribe( result => {
     if(result['ok']){
         this.snackBar.openFromComponent(ToastComponent, { data: { message: result['ok'], level: "ok"}})
         this.router.navigate([`/users`])
     } else {
         const message = result['type'] == 'not unique' ? "duplicate username or e-mail" : result['error']
         this.snackBar.openFromComponent(ToastComponent, { data: { message: message, level: "error"}})
     }
 })
开发者ID:idot,项目名称:betterplay,代码行数:9,代码来源:register-user.component.ts


示例5: setTimeout

    this.sw.available.subscribe(evt => {
      const snack = this.snack.open('Dostępna aktualizacja', 'ODŚWIEŻ');

      snack.onAction()
        .subscribe(() => window.location.reload());

      setTimeout(() => {
        snack.dismiss();
      }, 7000);
    });
开发者ID:skalagi,项目名称:pogoda-cli,代码行数:10,代码来源:app.component.ts


示例6: setTimeout

 setTimeout(() => {
     this.matSnackBar.open('');
     this.matSnackBar.open(
         this.translate.instant('The link is broken. Please contact your system administrator.'),
         this.translate.instant('OK'),
         {
             duration: 0
         }
     );
     this.router.navigate(['/login']);
 });
开发者ID:CatoTH,项目名称:OpenSlides,代码行数:11,代码来源:reset-password-confirm.component.ts


示例7: map

 map(connected =>
   connected
   ? this.snackBar.open(`Connected to Dotstar`, '', {
       panelClass: ['bgc-green', 'c-black'],
       duration: 3000,
       verticalPosition: 'top',
     })
   : this.snackBar.open(`Connection closed`, 'Reconnect', {
       duration: 3000,
       verticalPosition: 'top',
     })
开发者ID:alexeden,项目名称:dotstar-node,代码行数:11,代码来源:dotstar-notifiers.component.ts


示例8: copySource

 /**
  * Copy the source
  *
  * @param {string} text
  */
 copySource(text: string): void
 {
     if ( this._fuseCopierService.copyText(text) )
     {
         this._matSnackBar.open('Code copied', '', {duration: 2500});
     }
     else
     {
         this._matSnackBar.open('Copy failed. Please try again!', '', {duration: 2500});
     }
 }
开发者ID:karthik12ui,项目名称:fuse-angular-full,代码行数:16,代码来源:example-viewer.ts


示例9:

 d => {
   if (d.success) {
     this.snackBar.open(d.msg, '', {
       duration: 5000,
     });
   } else {
     this.snackBar.open(d.msg, '', {
       duration: 5000,
     });
     this.loadEmail = true;
   }
 }, (err) => {
开发者ID:camilolozano,项目名称:finalAndroid2018-front,代码行数:12,代码来源:login.component.ts


示例10: toggleSetting

 public async toggleSetting(setting: string, value: boolean) {
   try {
     const newSetting = { [setting]: !value };
     const dictionary = await this.dictionariesService.currentDictionary.pipe(first()).toPromise();
     await this.afs.doc(`dictionaries/${dictionary.id}/config/settings`).set(newSetting, { merge: true });
     this.snackBar.open('Setting updated', '', { duration: 2000 });
   } catch (err) {
     this.snackBar.open('Failed to update setting.', '', {
       panelClass: 'snackbar-error',
       duration: 3000
     });
   }
 }
开发者ID:jacobbowdoin,项目名称:RapidWords,代码行数:13,代码来源:settings.service.ts


示例11: onSubmit

 onSubmit() {
   // this method is called if the contact is valid and dirty (no point updating if no changes made)
   this.snackBar.open('Contact created.', '', {duration: 3000});
   this.contact.photo = 'https://robohash.org/etquasiqui.jpg?size=250x250&set=set1';
   this.contactService.createContact(this.contact);
   this.router.navigate(['contacts']);
 }
开发者ID:Rockncoder,项目名称:ng-contacts,代码行数:7,代码来源:contact-new.component.ts


示例12: reaction

 reaction(() => this.authStore.authError, (authError) => {
   if (authError) {
     this.snackBar.open(authError, '', {
       duration: 3000
     });
   }
 });
开发者ID:reisub0,项目名称:mainflux,代码行数:7,代码来源:app.component.ts


示例13: displaySimpleAlert

    public displaySimpleAlert(alert: SimpleAlert) {

        this.snackBar.open(alert.message, alert.action || 'OK', {
            duration: alert.duration || 500,
            verticalPosition: "top"
          });
    }
开发者ID:grecosoft,项目名称:NetFusion,代码行数:7,代码来源:AlertService.ts


示例14: reaccionar

 reaccionar(value) {
   if (this.authService.isAuthenticated()) {
     if ((this.miReaccion.like && value === 1) || (this.miReaccion.dislike && value === 2)) {
       return this.eliminarReaccion();
     }
     const reaccion = {
       comentario_id: this.comentario._id,
       reaccion: value
     };
     this.reaccionService.reaccionar(reaccion)
     .subscribe(res => {
       if (res.status) {
         this.comentarioService.obtenerComentario(this.comentario._id)
         .subscribe(resComentario => {
           if (resComentario.status) {
             const newComentario = resComentario.comentario;
             newComentario.user = this.comentario.user;
             this.comentario = newComentario;
             this.ngOnInit();
             this.snackBar.open('Se ha guardado', 'Ok', {
               duration: 2000
             });
           }
         });
       }
     });
   } else {
     this.snackBar.open('Debe estar registrado', 'Login', {
       duration: 4000
     }).onAction().subscribe(result => {
       this.router.navigate(['/login']);
     });
   }
 }
开发者ID:daividix,项目名称:Tumer,代码行数:34,代码来源:comment.component.ts


示例15: submitNewPassword

    /**
     * Submit the new password.
     */
    public async submitNewPassword(): Promise<void> {
        if (this.newPasswordForm.invalid) {
            return;
        }

        try {
            await this.http
                .post<void>(environment.urlPrefix + '/users/reset-password-confirm/', {
                    user_id: this.user_id,
                    token: this.token,
                    password: this.newPasswordForm.get('password').value
                })
                .toPromise();
            // TODO: Does we get a response for displaying?
            this.matSnackBar.open(
                this.translate.instant('Your password was resetted successfully!'),
                this.translate.instant('OK'),
                {
                    duration: 0
                }
            );
            this.router.navigate(['/login']);
        } catch (e) {
            console.log('error', e);
        }
    }
开发者ID:jwinzer,项目名称:OpenSlides,代码行数:29,代码来源:reset-password-confirm.component.ts


示例16: displaySuccess

 displaySuccess(message: string, duration: number = 4000, action?: string): void {
   this.snackBar.open(message, action, {
     announcementMessage: message,
     duration,
     panelClass: 'success-snackbar'
   });
 }
开发者ID:pastorsj,项目名称:bannablog,代码行数:7,代码来源:snackbar-messaging.service.ts


示例17: displayErrorMessage

 displayErrorMessage(error: string, duration: number = 4000, action?: string): void {
   this.snackBar.open(error, action, {
     announcementMessage: error,
     duration,
     panelClass: 'error-snackbar'
   });
 }
开发者ID:pastorsj,项目名称:bannablog,代码行数:7,代码来源:snackbar-messaging.service.ts


示例18: onModifyPoliciesClicked

  public onModifyPoliciesClicked(client: Client): void {
    if (!this.policies || this.loadingPolicies) {
      this.snackbar.open("Please wait until the policies have been loaded", "OK", {
        duration: 1000
      });

      return;
    }

    if (this.policies.length == 0) {
      this.snackbar.open("Please create a policy to continue", "OK", {
        duration: 1000
      });

      return;
    }

    let assignmentDialog = this.dialog.open(PolicyAssignmentDialog, {
      data: {
        client: client,
        policies: this.policies
      }
    });

    assignmentDialog
      .afterClosed()
      .subscribe(dialogResult => {
        if (!dialogResult) {
          return;
        }

        let assignmentResult = dialogResult.result as PolicyAssignmentResult;
        if (assignmentResult != PolicyAssignmentResult.Success) {
          return;
        }

        let clientResult = dialogResult.client as Client;
        let clientIndex = this.clients.indexOf(client);
        this.clients[clientIndex] = clientResult;
        // TODO: Update the policies in-place instead of reloading them
        this.loadPolicies();

        this.snackbar.open(`${clientResult.name}'s policies have been updated successfully`, "OK", {
          duration: 5000
        });
      });
  }
开发者ID:Machinarius,项目名称:GAPInsurance,代码行数:47,代码来源:dashboard.component.ts


示例19: handleSave

  handleSave(id: number) {
    let hasIdAssignedAlready = this.data.service.id && this.data.service.id > 0;

    if (!hasIdAssignedAlready && id && id != -1) {
      this.data.service.id = id;
      this.snackBar.open(this.messages.services_form_alert_serviceAdded,"Dismiss", {
        duration: 5000
      });
    } else {
      this.snackBar.open(this.messages.services_form_alert_serviceUpdated,"Dismiss", {
        duration: 5000
      });
    }

    this.data.service.id = id;
    this.location.back();
  }
开发者ID:mm999,项目名称:cas,代码行数:17,代码来源:form.component.ts


示例20:

 this.zone.run(() => {
   this.snackBar.open(error, 'close', {
     duration: 5000,
     horizontalPosition: 'right',
     verticalPosition: 'top',
     panelClass: ['sb-error']
   });
 });
开发者ID:jterral,项目名称:grim-app,代码行数:8,代码来源:notification.service.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript material.MatTable类代码示例发布时间:2022-05-28
下一篇:
TypeScript material.MatSidenav类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap