本文整理匯總了TypeScript中ng2-toastr.ToastsManager類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ToastsManager類的具體用法?TypeScript ToastsManager怎麽用?TypeScript ToastsManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ToastsManager類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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!');
}
}
示例2: constructor
constructor(private toastr: ToastsManager, vRef: ViewContainerRef,
public router: Router,
public cognitoLoginService: CognitoLoginService) {
this.toastr.setRootViewContainerRef(vRef);
}
示例3: saveEmergency
saveEmergency() {
if (this.formEmergency.valid) {
if (this.patients.length > 0) {
const emergency = {
date: this.formEmergency.get('date').value,
type_emergency: this.formEmergency.get('category').value,
driver: this.driverSelected,
ambulance: this.ambulanceSelected,
paramedic: this.paramedicsSelected,
patient: this.patients,
location: {
type: 'Point',
coordinates: this.positions
}
};
this.formEmergency.reset({
driver: '',
ambulance: '',
paramedics: ''
});
this._emergencyService.save(emergency).subscribe(
(res) => {
console.log(res.json());
},
(error) => {
console.log(error.json());
}
);
}else{
this._toast.info('Debe ingresar al menos un paciente', 'Emergencias!');
}
}else{
this._toast.info('Todos los campos marcados con * son obligatorios', 'Emergencias!');
}
}
示例4:
}, error => {
if (error.status === 401) {
this._toastr.error('Невозможно войти с предоставленными данными', 'Ошибка!');
} else {
this._toastr.error('Что-то пошло не так', 'Ошибка!');
}
});
示例5: ngOnInit
ngOnInit(): void {
this.toastr.setRootViewContainerRef(this._vcr);
this.toastr.onClickToast().subscribe( toast => {
this.toastr.dismissToast(toast);
});
this._tokenService.init({
apiPath: 'api',
signInRedirect: 'auth'
});
}
示例6: save
save() {
if (this.formParamedics.valid) {
const paramedic = {
name: this.formParamedics.get('name').value,
lastname: this.formParamedics.get('lastname').value,
phone: this.formParamedics.get('phone').value,
cellPhone: this.formParamedics.get('cellPhone').value,
gender: this.formParamedics.get('gender').value,
birthdate: this.formParamedics.get('birthdate').value,
specialization: this.formParamedics.get('specialization').value
};
this._paramedicsService.save(paramedic).subscribe(
(res) => {
this._toast.success(`Se registro el paramedico ${res.json().name}`, 'Paramedicos!');
this.formParamedics.reset({
gender: ''
})
},
(error) => {
console.log(error.json());
this._toast.error(`Ocurrio un error al registrar al paramedico`, 'Paramedicos!');
}
);
}else {
this._toast.info(`Todos los campos marcados con * son obligatorios`, 'Paramedicos!');
}
}
示例7: saveAmbulance
saveAmbulance() {
if (this.formAmbulance.valid) {
const ambulance = {
car: this.formAmbulance.get('car').value,
car_plate: this.formAmbulance.get('car_plate').value,
type_ambulance: this.formAmbulance.get('type_ambulance').value,
available: this.formAmbulance.get('available').value
};
this.formAmbulance.reset({
car: '',
car_plate: '',
type_ambulance: '',
available: ''
});
this._ambulanceService.save(ambulance).subscribe(
(res) => {
console.log(res.json());
},
(error) => {
console.log(error.json());
}
);
}else {
this._toast.info('Todos los campos marcados con * son obligatorios', 'Ambulancias!');
}
}
示例8: toastWarning
/*
* Displays a warning message
*/
toastWarning(reason?: string)
{
let key: string;
switch(reason)
{
case 'accessDenied':
key = 'TOASTR.WARNING.ACCESS';
break;
case 'noResult':
key = 'TOASTR.WARNING.TIMEOUT';
break;
case 'timeout':
key = 'TOASTR.WARNING.TIMEOUT';
break;
default:
key = 'TOASTR.WARNING.DEFAULT';
break;
}
let message: string;
this.translateService.get(key).subscribe(
value => {
message = value;
});
this.toastr.warning(message)
}
示例9: toastInfo
/*
* Displays an info message
*/
toastInfo(reason?: string)
{
let message: string;
let key: string;
switch(reason)
{
case 'jobRegistered':
key = 'TOASTR.INFO.JOB';
break;
case 'noResult':
key = 'TOASTR.INFO.NORESULT';
break;
case'restartNeeded':
key = 'TOASTR.INFO.RESTART';
break;
default:
key = 'TOASTR.INFO.DEFAULT';
break;
}
this.translateService.get(key).subscribe(
value => {
message = value;
});
this.toastr.info(message)
}
示例10: 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);
}