Import

import-toast.ts
import { NuiToaster, NuiToasterRegion } from '@needless-ui/angular/toast';

NuiToaster

Service สำหรับแสดง Toast ใช้ inject ได้จากทุกที่

Selector
inject(NuiToaster)
NuiToaster: พร็อพเพอร์ตี
ชื่อชนิดค่าเริ่มต้นคำอธิบาย
toastsเมธอดSignal<readonly NuiToast[]>Toast ทุกอันที่อยู่บนหน้าจอ เรียงจากอันล่าสุด
showเมธอด(options: NuiToastOptions | string) => NuiToastRefแสดง Toast โดยส่งหัวเรื่อง หรือตัวเลือกที่มีคำอธิบาย โทนสี ระยะเวลา คำสั่ง หรือ id
successเมธอด(title, options?) => NuiToastRefแสดง Toast แบบสำเร็จ
warningเมธอด(title, options?) => NuiToastRefแสดง Toast แบบคำเตือน
dangerเมธอด(title, options?) => NuiToastRefแสดง Toast แบบ danger ซึ่งจะแสดงอยู่ 8 วินาทีและถูกประกาศทันที
promiseเมธอด(promise, messages) => Promiseแสดง Toast กำลังโหลดจนกว่า promise จะเสร็จสิ้น จากนั้นแสดงข้อความสำเร็จหรือ danger
dismissเมธอด(id?: string) => voidปิด Toast หนึ่งอัน หรือปิดทั้งหมด

NuiToasterRegion

พื้นที่ที่ Toast ปรากฏ วางไว้เพียงครั้งเดียวใน app shell

Selector
nui-toaster
NuiToasterRegion: พร็อพเพอร์ตี
ชื่อชนิดค่าเริ่มต้นคำอธิบาย
positionInput'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end''bottom-end'มุมหรือขอบของ viewport ด้านต้นและด้านท้ายจะเป็นไปตามทิศทางของข้อความ
expandedInputbooleanfalseให้กอง Toast กางออกอยู่เสมอ
labelInputstring'Notifications (Alt+T)'ชื่อที่เข้าถึงได้ของพื้นที่ ควรบอกวิธีไปยังพื้นที่นี้ด้วย
closeLabelInputstring'Dismiss'ชื่อที่เข้าถึงได้ของปุ่มปิด
hotkeyInputstring'KeyT'ปุ่มที่ใช้ร่วมกับ Alt เพื่อย้ายโฟกัสไปยัง Toast ล่าสุด ระบุเป็นค่า KeyboardEvent.code