當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ng-vcl.AlertService類代碼示例

本文整理匯總了TypeScript中@ng-vcl/ng-vcl.AlertService的典型用法代碼示例。如果您正苦於以下問題:TypeScript AlertService類的具體用法?TypeScript AlertService怎麽用?TypeScript AlertService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AlertService類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: retry

  retry() {
    // This fake async request will fail the first time
    let fails = 0;
    const fakeAsync = async(new Date().toLocaleTimeString(), () => ++fails <= 1);

    // Add a retry routine using an alert
    const fakeAsyncWithRetries = fakeAsync.pipe(retryWhen(errors => {
      return errors.pipe(switchMap(err => {
        return this.alert.open({
          text: 'Retry?',
          type: AlertType.Warning,
          showCancelButton: true,
        });
      }));
    }));

    this.alert.open({
      text: 'Show current time? (will fail the first time)',
      showCancelButton: true,
      confirmAction: fakeAsyncWithRetries
    }).subscribe(result => {
      this.alert.info(result.value, { title: 'Time' });
    }, err => {
      console.log(err);
      this.alert.error(String(err ? err.reason : err), { title: 'Error' });
    });
  }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:27,代碼來源:demo.component.ts

示例2:

 return errors.pipe(switchMap(err => {
   return this.alert.open({
     text: 'Retry?',
     type: AlertType.Warning,
     showCancelButton: true,
   });
 }));
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:7,代碼來源:demo.component.ts

示例3: loader

 loader() {
   this.alert.open({
     title: 'Loading',
     text: 'Hit esc to close loader',
     loader: true,
     showConfirmButton: false
   });
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:8,代碼來源:demo.component.ts

示例4: async

 async() {
   this.alert.open({
     text: 'Determine your user agent?',
     confirmAction: async(window.navigator.userAgent),
     showCancelButton: true
   }).subscribe(result => {
     this.alert.info(result.value, {
       title: 'Your user agent'
     });
   }, err => {
     this.alert.error('Could not determine user agent');
   });
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:13,代碼來源:demo.component.ts

示例5: Error

 inputText() {
   this.alert.open({
     text: 'What is your name?',
     input: AlertInput.Text,
     confirmButtonLabel: 'Next',
     inputValidator: (value) => {
       if (typeof value !== 'string' || value.length < 2) {
         throw new Error('This is not your name!');
       }
       return true;
     }
   }).subscribe(result => {
     this.alert.info('Hello ' + result.value);
   }, this.alert.noop);
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:15,代碼來源:demo.component.ts

示例6: question

 question() {
   this.alert.open({
     text: 'Do you really want to delete the file?',
     title: 'Delete file?',
     type: AlertType.Question,
     showCloseButton: true,
     showCancelButton: true,
     cancelButtonLabel: 'No',
     confirmButtonLabel: 'Yes'
   }).subscribe((result) => {
     this.alert.success('File deleted');
   }, err => {
     this.alert.error('Reason: ' + err.reason , { title: 'File not deleted' });
   });
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:15,代碼來源:demo.component.ts

示例7: custom

 custom() {
   this.alert.open({
     text: 'This is a bit customized...',
     title: 'Information',
     type: AlertType.Info,
     showCloseButton: true,
     showCancelButton: true,
     confirmButtonClass: 'vclSuggestive',
     confirmButtonPrepIcon: 'fas:bolt',
     cancelButtonColor: 'orange',
     customClass: 'vclScale130p',
     titleAlignment: AlertAlignment.Center,
     contentAlignment: AlertAlignment.Center,
     buttonAlignment: AlertAlignment.Center,
   });
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:16,代碼來源:demo.component.ts

示例8: error

 error() {
   this.alert.error('This is an error', {
     title: 'An error'
   });
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:5,代碼來源:demo.component.ts

示例9: success

 success() {
   this.alert.success('You are successful', {
     title: 'A success'
   });
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:5,代碼來源:demo.component.ts

示例10: warning

 warning() {
   this.alert.warning('This is a warning', {
     title: 'A warning'
   });
 }
開發者ID:ng-vcl,項目名稱:ng-vcl,代碼行數:5,代碼來源:demo.component.ts


注:本文中的@ng-vcl/ng-vcl.AlertService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。