자연어 설명만으로 Standalone 사양의 Angular 디렉티브 및 예시 코드를 작성할 때 사용합니다.
You are an expert Angular developer. Generate a complete Angular directive based on the following description:
Directive Description: ${description}
Directive Type: [structural | attribute]
Selector Name: [e.g. appHighlight, *appIf]
Inputs needed: [list any @Input() properties]
Target element behavior: ${what_should_happen_to_the_host_element}
Generate:
1. The full directive TypeScript class with proper decorators
2. Any required imports
3. Host bindings or listeners if needed
4. A usage example in a template
5. A brief explanation of how it works
Use Angular 17+ standalone directive syntax. Follow Angular style guide conventions.당신은 전문 Angular 개발자입니다. 다음 설명을 바탕으로 완벽한 Angular 디렉티브를 생성하세요: 디렉티브 설명: [설명 입력] 디렉티브 타입: [structural | attribute] 셀렉터 이름: [예: appHighlight, *appIf] 필요한 입력값: [필요한 @Input() 속성 목록] 타깃 엘리먼트 동작: [호스트 엘리먼트에 일어날 동작] 생성할 항목: 1. 적절한 데코레이터가 포함된 전체 디렉티브 TypeScript 클래스 2. 필요한 모든 임포트 문 3. 필요한 경우 Host binding 또는 listener 4. 템플릿에서의 사용 예시 5. 작동 방식에 대한 간단한 설명 Angular 17+ 독립형(standalone) 디렉티브 문법을 사용하세요. Angular 스타일 가이드 규칙을 준수하세요.
출처 · prompts.chat · Angular Directive Generator — 원문은 출처에 게시된 그대로이며, 권리는 원작자에게 있습니다.
Gemini로 실행한 결과입니다. 입력 항목에는 국내 환경의 예시값을 적용했습니다(AI 생성 — 사실 확인 필요).
You are an expert Angular developer. Generate a complete Angular directive based on the following description: Directive Description: 마우스 호버 시 요소의 배경색과 글자색을 동적으로 변경하는 하이라이트 디렉티브 Directive Type: attribute Selector Name: appHighlight Inputs needed: appHighlight (hover color string), defaultColor (default color string) Target element behavior: 마우스가 요소 위에 올라가면 지정된 하이라이트 색상으로 변경되고, 마우스가 벗어나면 기본 색상으로 복원됨 Generate: 1. The full directive TypeScript class with proper decorators 2. Any required imports 3. Host bindings or listeners if needed 4. A usage example in a template 5. A brief explanation of how it works Use Angular 17+ standalone directive syntax. Follow Angular style guide conventions.
import { Directive, ElementRef, HostListener, Input, Renderer2 } from '@angular/core';
@Directive({
selector: '[appHighlight]',
standalone: true
})
export class HighlightDirective {
@Input() appHighlight = '#ffe0b2'; // 호버 시 배경색
@Input() defaultColor = 'transparent'; // 기본 배경색
constructor(private el: ElementRef, private renderer: Renderer2) {}
@HostListener('mouseenter') onMouseEnter() {
this.setBackground(this.appHighlight || '#ffe0b2');
}
@HostListener('mouseleave') onMouseLeave() {
this.setBackground(this.defaultColor);
}
private setBackground(color: string) {
this.renderer.setStyle(this.el.nativeElement, 'backgroundColor', color);
}
}<div [appHighlight]="'#b3e5fc'" defaultColor="#f5f5f5"> 마우스를 올리면 배경색이 변경됩니다. </div>
standalone: true 구문을 사용한 속성(Attribute) 디렉티브입니다.@Input()을 통해 호버 색상과 기본 색상을 전달받습니다.@HostListener로 마우스 진입/이탈 이벤트를 감지하여 Renderer2로 DOM 스타일을 안전하게 변경합니다.mopick 개선안
원문을 그대로 넣으면 AI 가 매번 다르게 답하거나 중요한 부분을 빠뜨릴 수 있습니다. 개선안은 원문의 뜻과 언어는 그대로 두고 역할 · 바꿔 넣을 입력 칸 · 결과 형식 · 지킬 조건을 보완해 다시 쓴 버전입니다. 원문과 같은 곳(ChatGPT · Claude 등)에 그대로 붙여 넣어 쓰면 됩니다.
AI 자체 평가 — 개선안을 쓴 AI 가 명확성 · 구체성 · 결과 형식 · 재사용성 기준(100점)으로 직접 매긴 점수 · 결과를 돌려 검증한 값은 아님
입력 칸레슨 05 배우기 ›
원문 · 4개바꿔 넣을 자리가 일부만 표시돼 있어 쓸 때마다 원문을 고쳐야 했습니다.
개선 · 8개[Describe directive purpose] · [e.g., appHighlight or *appIf] · [List inputs, e.g., color: string] 외 1개
결과 형식레슨 03 배우기 ›
원문 · 정해지지 않음결과를 어떤 모양으로 낼지 정해져 있지 않아 답 모양이 매번 달라질 수 있었습니다.
개선 · 형식을 지정함2. Usage Example: HTML template snippet demonstrating proper usage.
이 개선안에 쓰인 기법 — 프롬프트 클래스에서 배우기
원문
You are an expert Angular developer. Generate a complete Angular directive based on the following description:
Directive Description: ${description}
Directive Type: [structural | attribute]
Selector Name: [e.g. appHighlight, *appIf]
Inputs needed: [list any @Input() properties]
Target element behavior: ${what_should_happen_to_the_host_element}
Generate:
1. The full directive TypeScript class with proper decorators
2. Any required imports
3. Host bindings or listeners if needed
4. A usage example in a template
5. A brief explanation of how it works
Use Angular 17+ standalone directive syntax. Follow Angular style guide conventions.개선안 · 색칠한 [칸]에 내 내용을 넣어 쓰세요
You are an expert Angular developer. Generate a complete, production-ready Angular directive based on the following parameters: - Description: [Describe directive purpose] - Type: [structural | attribute] - Selector: [e.g., appHighlight or *appIf] - Inputs: [List inputs, e.g., color: string] - Target Element Behavior: [Describe host element behavior/events] Output Requirements: 1. Full TypeScript Code: Complete code block with imports, directive decorator (`standalone: true`), host bindings/listeners, and modern signals (e.g., `input()`). 2. Usage Example: HTML template snippet demonstrating proper usage. 3. Brief Explanation: Key logic, lifecycle handling, and cleanup strategy if applicable. Constraints: - Strictly follow Angular 17+ standalone directive syntax and Angular Style Guide. - Ensure strict TypeScript typing without using `any`. - Do not use placeholders or truncated code in the implementation.