你可以使用toastr。更多信息可以在 https://www.npmjs.com/package/toastr 。演示是在 https://codeseven.github.io/toastr/demo.html
用于展示烤面包机 NGX-toastr 图书馆
脚步:
1) npm install ngx-toastr --save
npm install ngx-toastr --save
2)遵循其他设置 这里
快速代码:
import { ToastrService } from 'ngx-toastr'; constructor(private toastr: ToastrService) {} saveStudentDetails(values) { const studentData = {}; studentData['id'] = values.id; studentData['password'] = values.password; this.crudService.loginstudent(studentData).subscribe(result => { this.student = result; this.router.navigate(['/address']); }, err => { console.log('status code ->' + err.status); this.toastr.error('Hello world!', 'Toastr fun!'); });
您可以使用任何第三方烤面包机 NGX-toastr 显示错误烤面包机通知。
例如,使用ngx-toastr:
constructor( ... private toastr: ToastrService ) {} this.crudService.loginstudent(studentData).subscribe( result => { this.student = result; this.router.navigate(['/address']); this. toastr.success('Logged in'); }, err => { console.log('status code ->' + err.status); this. toastr.error('Please try again'); } );