본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

알림

원문 보기 위키 갱신

알림 (Notification)

전역으로 알림 메시지를 표시해요.

출처: 문서

본문

언제 사용하나요

뷰포트의 네 모서리 중 어느 곳에서든 알림 메시지를 표시할 때 사용해요. 주로 다음과 같은 경우에 사용할 수 있어요.

  • 복잡한 내용의 알림
  • 사용자 상호작용에 기반한 피드백을 제공하거나, 사용자가 따라야 할 다음 단계에 대한 세부 정보를 보여주는 알림
  • 애플리케이션에서 푸시되는 알림

API

NzNotificationService 서비스

이 컴포넌트는 여러 서비스 메서드를 제공하며 사용법과 파라미터는 다음과 같아요.

  • NzNotificationService.blank(title, content, [options]) // 아이콘이 없는 알림
  • NzNotificationService.success(title, content, [options])
  • NzNotificationService.error(title, content, [options])
  • NzNotificationService.info(title, content, [options])
  • NzNotificationService.warning(title, content, [options])
Argument Description Type Default
title 제목 string | TemplateRef<void> -
content 알림 내용 NzNotificationContentType -
options 현재 알림 박스의 파라미터 설정을 지원해요. 아래 표를 참고하세요 object -

options로 설정 가능한 파라미터는 다음과 같아요.

Argument Description Type
nzKey 알림의 고유 식별자 string
nzDuration 표시 시간(밀리초). 0으로 설정하면 사라지지 않아요 number
nzPauseOnHover true로 설정하면 마우스가 위에 있을 때 자동으로 제거되지 않아요 boolean
nzAnimate 애니메이션 활성화 여부 boolean
nzStyle 커스텀 인라인 스타일 object
nzClass 커스텀 CSS 클래스 object
nzData 템플릿 컨텍스트로 사용될 모든 값 any
nzCloseIcon 커스텀 닫기 아이콘 TemplateRef<void> | string
nzButton 커스텀 버튼 TemplateRef<{ $implicit: NzNotificationComponent }> | string

파괴(destruction)를 위한 메서드도 제공돼요.

  • NzNotificationService.remove(id) // 지정된 id의 알림을 제거해요. id가 비어 있으면 모든 알림을 제거해요 (알림 id는 위 메서드에서 반환돼요)

전역 설정 (Global Configuration)

NzConfigService를 사용해 이 컴포넌트를 전역으로 설정할 수 있어요. 자세한 내용은 전역 설정 챕터를 확인하세요.

Parameter Description Type Default
nzDuration 표시 시간(밀리초). 0으로 설정하면 사라지지 않아요 number 4500
nzMaxStack 동시에 표시할 수 있는 최대 알림 수 number 8
nzPauseOnHover true로 설정하면 마우스가 위에 있을 때 자동으로 제거되지 않아요 boolean true
nzAnimate 애니메이션 활성화 여부 boolean true
nzTop 위쪽에서 팝업될 때 알림의 위쪽 위치 string '24px'
nzBottom 아래쪽에서 팝업될 때 알림의 아래쪽 위치 string '24px'
nzPlacement 팝업 위치. topLeft, topRight, bottomLeft, bottomRight, top, bottom 중 선택 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'top' | 'bottom' 'topRight'
nzDirection 알림 텍스트의 방향 'ltr' | 'rtl' -

NzNotificationRef

NzNotificationService.success 등을 호출했을 때 반환되는 객체예요.

export interface NzNotificationRef {
  messageId: string;
  onClose: Subject<boolean>; // 알림이 닫힐 때 이벤트를 발생시키고, 사용자가 닫으면 `true`를 발생시켜요
  onClick: Subject<MouseEvent>;
}

더 알아보기 (Learn more)