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

Mention 멘션

원문 보기 위키 갱신

Mention 멘션 (Mention)

Mention은 입력창에서 누군가나 무언가를 언급(@멘션)하는 데 쓰는 컴포넌트예요. 제안 목록을 띄워 선택할 수 있고, Form과 연동하거나 비활성화·읽기 전용, 자동 크기, 상태, 변형 등을 지원합니다.

출처: 문서

본문

입력창에서 누군가나 무언가를 언급할 때 사용하는 컴포넌트예요.

언제 사용하나요?

누군가나 무언가를 언급해야 할 때 사용해요.

API

기본 구조는 다음과 같아요.

<nz-mention [nzSuggestions]="suggestions">
  <textarea nz-input [(ngModel)]="value" nzMentionTrigger> </textarea>
</nz-mention>

nz-mention 컴포넌트

속성 설명 타입 기본값 버전
[nzMentionTrigger] 트리거 요소(필수)예요 HTMLTextAreaElement | HTMLInputElement -
[nzMentionSuggestion] 제안 템플릿을 커스터마이즈해요 TemplateRef<any> -
[nzLoading] 로딩 모드예요 boolean false
[nzNotFoundContent] 제안이 비었을 때의 안내예요 string '无匹配结果,轻敲空格完成输入'
[nzPlacement] 대상에 대한 제안의 위치예요. top과 bottom 중 하나일 수 있어요 'button' | 'top' | 'bottom'
[nzPrefix] Mention이 목록을 보여 주도록 트리거하는 문자예요 string | string[] '@'
[nzSuggestions] 제안 콘텐츠예요 any[] []
[nzStatus] 검증 상태 설정이에요 'error' | 'warning' -
[nzAllowClear] clear 아이콘으로 멘션 콘텐츠를 지울 수 있는지 여부예요 boolean false 20.3.0
[nzClearIcon] 커스텀 clear 아이콘이에요 TemplateRef<void> - 20.3.0
[nzVariant] Input의 변형(variant)이에요 'outlined' | 'filled' | 'borderless' | 'underlined' 'outlined' 20.3.0
[nzValueWith] 제안의 값을 매핑하는 함수예요 (any) => string (value: string) => string
(nzOnSelect) 제안에서 선택했을 때 호출되는 콜백이에요 EventEmitter<any> -
(nzOnSearchChange) 검색 콘텐츠가 바뀔 때 호출되는 콜백이에요 EventEmitter<MentionOnSearchTypes> -
(nzOnClear) clear 버튼을 클릭했을 때 호출되는 콜백이에요 EventEmitter<void> -

메서드

이름 설명
getMentions input[nzMentionTrigger] 안의 멘션 배열을 가져와요

nzMentionTrigger

트리거 요소예요.

<nz-mention>
  <textarea nzMentionTrigger></textarea>
</nz-mention>
<nz-mention>
  <input nzMentionTrigger />
</nz-mention>

nzMentionSuggestion

제안 템플릿을 커스터마이즈해요.

<nz-mention [nzSuggestions]="items" [nzValueWith]="valueWith">
  <input nz-input nzMentionTrigger />
  <ng-container *nzMentionSuggestion="let item">
    <span>{{ item.label }} - {{ item.value }}</span>
  </ng-container>
</nz-mention>

MentionOnSearchTypes

속성 설명 타입 기본값
value 검색 키워드예요 string -
prefix 접두사예요 string -

FAQ

Q: 스크롤할 때 오버레이 레이어 요소가 스크롤 위치를 따라가지 않아요

기본적으로 오버레이 레이어 요소는 body를 스크롤 컨테이너로 사용해요. 다른 스크롤 컨테이너를 쓴다면, 커스텀 스크롤 컨테이너 요소에 CdkScrollable 디렉티브를 추가하세요.

메모: @angular/cdk/scrolling에서 CdkScrollable 디렉티브 또는 ScrollingModule 모듈을 임포트해야 해요.

더 알아보기 (Learn more)

nzPrefix로 트리거 문자를 여러 개 지정할 수 있고(string[]), nzMentionSuggestion·nzValueWith로 제안 표시와 값 매핑을 커스터마이즈할 수 있어요. getMentions()로 입력된 멘션 목록을 가져올 수 있어요.