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


TypeScript web.MdcSnackbar類代碼示例

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


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

示例1: describe

describe('MdcSnackbar', () => {
  let snackbar: MdcSnackbar;
  let simpleMessage = 'Simple message!';
  let simpleActionLabel = 'Ok';

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [MdcSnackbarModule],
      declarations: [SimpleSnack]
    });

    TestBed.compileComponents();
  }));

  describe('behaviors', () => {
    let testSnackbar: MdcSnackbar;
    let fixture: ComponentFixture<any>;

    beforeEach(() => {
      fixture = TestBed.createComponent(SimpleSnack);
      snackbar = fixture.componentInstance.snackbar;
      fixture.detectChanges();
    });

    it('#should open a simple message', () => {
      snackbar.show(simpleMessage);
    });

    it('#should open a simple message with a button', fakeAsync(() => {
      let snackbarRef = snackbar.show(simpleMessage, simpleActionLabel);
      fixture.detectChanges();
      tick(1000);

      snackbarRef.componentInstance.actionButton.nativeElement.click();
      fixture.detectChanges();
      flush();
    }));

    it('#should open a snackbar with config', () => {
      let snackbarRef = snackbar.show(simpleMessage, simpleActionLabel, { timeout: 3000, align: 'start', focusAction: true });
      expect(snackbar.isShowing()).toBe(true);
      fixture.detectChanges();

      snackbar.dismiss();
      expect(snackbar.isShowing()).toBe(false);
    });

    it('#should close an open snackbar', fakeAsync(() => {
      let snackbarRef = snackbar.show(simpleMessage);
      fixture.detectChanges();
      tick(1000);

      snackbarRef = snackbar.show(simpleMessage);
      fixture.detectChanges();
      flush();
    }));
  });
});
開發者ID:cd8608,項目名稱:angular-mdc-web,代碼行數:58,代碼來源:snackbar.test.ts

示例2: it

    it('#should open a snackbar with config', () => {
      let snackbarRef = snackbar.show(simpleMessage, simpleActionLabel, { timeout: 3000, align: 'start', focusAction: true });
      expect(snackbar.isShowing()).toBe(true);
      fixture.detectChanges();

      snackbar.dismiss();
      expect(snackbar.isShowing()).toBe(false);
    });
開發者ID:cd8608,項目名稱:angular-mdc-web,代碼行數:8,代碼來源:snackbar.test.ts

示例3:

 () => {
   // FIXME send to sentry
   this.snackbar.open(
     'An error occurred while removing the item. This may happened because the underlying TheMovieDB service returned an invalid response. '
       + 'Please refresh the page an try again!',
     'Close',
     this.getSnackbarConfig()
   );
 }
開發者ID:dArignac,項目名稱:treasury,代碼行數:9,代碼來源:movie-list.component.ts


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