本文整理匯總了TypeScript中ng2-toastr.ToastsManager.error方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ToastsManager.error方法的具體用法?TypeScript ToastsManager.error怎麽用?TypeScript ToastsManager.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ng2-toastr.ToastsManager
的用法示例。
在下文中一共展示了ToastsManager.error方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
}, error => {
if (error.status === 401) {
this._toastr.error('Невозможно войти с предоставленными данными', 'Ошибка!');
} else {
this._toastr.error('Что-то пошло не так', 'Ошибка!');
}
});
示例2: showError
showError(ngToast: ToastsManager, objError, status){
if(objError !== null && typeof objError === 'object')
{
if('error_description' in objError)
ngToast.error(objError.error_description, 'Ops!');
else if('message' in objError){
if(status == 401 || status === undefined){
if(objError.message !== 'Authorization has been denied for this request.')
ngToast.error(objError.message, 'Ops!');
else{
ngToast.error('Sua sessão expirou ou o acesso foi negado. Faça o login novamente.', 'Ops!');
this.sessionService.logout();
this.router.navigate(['/login']);
}
}
else
ngToast.error(objError.message, 'Ops!');
}
else
ngToast.error(objError, 'Ops!');
}
else{
if(typeof objError === 'string')
ngToast.error(objError, 'Ops!');
else if(objError === null && status == -1)
ngToast.error('Não foi possível conectar-se ao servidor.', 'Ops!');
else
ngToast.error('Ocorreu um erro ao realizar esta operação. Contate o suporte.', 'Ops!');
}
}
示例3: toastSetupError
/*
* Displays an error at setup
*/
toastSetupError(code :number)
{
let key: string;
switch(code)
{
case 1:
key = 'TOASTR.SETUP.SQLERROR';
break;
case 2:
key = 'TOASTR.SETUP.PATHERROR';
break;
case 4:
key = 'TOASTR.SETUP.USERERROR';
break;
case 5:
key = 'TOASTR.SETUP.USERERROR';
break;
case 6:
key = 'TOASTR.SETUP.SETERROR';
break;
default:
key = 'TOASTR.ERROR.DEFAULT';
}
let message: string
this.translateService.get(key).subscribe(
value => {
message = value;
});
this.toastr.error(message);
}
示例4: interceptAfter
public interceptAfter(interceptedResponse: InterceptedResponse): InterceptedResponse {
if (!interceptedResponse.response.ok && interceptedResponse.response.status !== 401) {
const errorMessage = interceptedResponse.response.json().error ||
interceptedResponse.response.statusText;
this.toastr.error(errorMessage);
}
return interceptedResponse;
}
示例5:
return this.http.get(verifyLink).map(response => {
const isValidToken = !!response.text();
if (!isValidToken) {
this.toastr.error('Неверный верификационный код');
this.router.navigate(['/']);
}
return isValidToken;
});
示例6: fbCallback
fbCallback(message: string, result: any) {
console.log('LoginComponent: fbCallback --> result ' + JSON.stringify(result));
if (message === null) {
this.router.navigate(['/ticket']);
} else {
this.toastr.error(message, 'Error!');
}
}
示例7: leftFeedback
leftFeedback() {
if (this.feedbackForm.valid) {
this._feedbackService.leftFeedback(this.feedbackForm.value).subscribe(() => {
this._toastr.success('Отзыв успешно отправлен', 'Успешно!');
this._router.navigateByUrl('/');
}, error => {
this._toastr.error('Что-то пошло не так', 'Ошибка!');
});
} else {
this._toastr.error('В форме присутствуют ошибки\nУбедитесь, что все поля заполненны верно', 'Ошибка!');
}
}
示例8: signUp
signUp() {
const equalPasswords = this.signUpForm.controls.password.value === this.signUpForm.controls.confirmPassword.value;
if (this.signUpForm.valid && equalPasswords) {
this._tokenService.registerAccount(
this.signUpForm.value.email,
this.signUpForm.value.password,
this.signUpForm.value.confirmPassword
).subscribe(res => {
this.router.navigateByUrl('');
},
error => {
this._toastr.error('Что-то пошло не так', 'Ошибка!');
});
} else {
this._toastr.error('Убедитесь, что все поля заполнены верно', 'Ошибка!');
}
}
示例9: switch
.catch((resp) => {
if (resp instanceof HttpErrorResponse) {
switch (resp.status) {
case 404:
this.router.navigate(['/404']);
break;
case 401:
this.authStorageService.remove();
this.router.navigate(['/login']);
// falls through
default:
this.toastr.error(resp.error.detail || '',
`${resp.status} - ${resp.statusText}`);
}
}
// Return the error to the method that called it.
return Observable.throw(resp);
});
示例10: onClick
@HostListener('click')
onClick() {
try {
// Create the input to hold our text.
const tmpInputElement = document.createElement('input');
tmpInputElement.value = this.getInputElement().value;
document.body.appendChild(tmpInputElement);
// Copy text to clipboard.
tmpInputElement.select();
document.execCommand('copy');
// Finally remove the element.
document.body.removeChild(tmpInputElement);
this.toastr.success('Copied text to the clipboard successfully.');
} catch (err) {
this.toastr.error('Failed to copy text to the clipboard.');
}
}