本文整理匯總了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();
}));
});
});
示例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);
});
示例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()
);
}