本文整理汇总了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' });
});
}
示例2:
return errors.pipe(switchMap(err => {
return this.alert.open({
text: 'Retry?',
type: AlertType.Warning,
showCancelButton: true,
});
}));
示例3: loader
loader() {
this.alert.open({
title: 'Loading',
text: 'Hit esc to close loader',
loader: true,
showConfirmButton: false
});
}
示例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');
});
}
示例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);
}
示例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' });
});
}
示例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,
});
}
示例8: error
error() {
this.alert.error('This is an error', {
title: 'An error'
});
}
示例9: success
success() {
this.alert.success('You are successful', {
title: 'A success'
});
}
示例10: warning
warning() {
this.alert.warning('This is a warning', {
title: 'A warning'
});
}