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