+ Adds strong keyboard and screen-reader support.
- Forced positioning and the SSR claim are flawed.
an expert Angular developer. Generate a complete Angular directive based on the following description: Directive Description: ${description} Directive
| Category | Development › Coding |
|---|---|
| Tags | DraftingDeveloperCodeTemplate |
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.Useful for quickly drafting an Angular directive. It asks for the TypeScript class, imports, host bindings or listeners, a template usage example, and a brief explanation.
Claude is the best-balanced and most accessible; Gemini is thorough but verbose. ChatGPT is concise but weaker on background restoration and lifecycle cleanup.
+ Adds strong keyboard and screen-reader support.
- Forced positioning and the SSR claim are flawed.
+ Presents the core solution clearly and concisely.
- It loses prior backgrounds and lacks destroy cleanup.
+ Implements every requested feature clearly.
- Repeated clicks may copy the tooltip text too.
| Criterion | ChatGPT | Claude | Gemini | Leader |
|---|---|---|---|---|
| Instruction following | 9 | 10 | 10 | Tie |
| Accuracy | 6 | 7 | 7 | Tie |
| Specificity | 9 | 9 | 9 | Tie |
| Structure | 8 | 9 | 9 | Tie |
| Right length | 9 | 8 | 6 | ChatGPT +13% |
Scored 1–10 by gpt-5.6-sol with model names hidden (2026-09-24). This is an AI review, not a measurement.
We gave three models the same input and copied their answers unedited. Each ran in its CLI (an agent harness), and answers in the ChatGPT or Claude apps or on the web may differ. Outputs are in Korean.
[Pasted material] Directive Description: 요소에 마우스를 올리면 배경색이 부드럽게 하이라이트되고, 클릭하면 해당 요소의 내용을 클립보드에 복사하는 디렉티브 Directive Type: attribute Selector Name: appCopyHighlight Inputs needed: highlightColor (string, 기본값 '#fef08a'), copyText (복사할 텍스트, 없으면 innerText 사용) Target element behavior: hover 시 배경색 트랜지션 적용, click 시 텍스트 복사 후 잠깐 '복사됨!' 툴팁 표시
import {
Directive,
ElementRef,
HostListener,
Input,
Renderer2,
inject,
} from '@angular/core';
@Directive({
selector: '[appCopyHighlight]',
standalone: true,
})
export class CopyHighlightDirective {
@Input() highlightColor = '#fef08a';
@Input() copyText?: string;
private readonly elementRef = inject(ElementRef<HTMLElement>);
private readonly renderer = inject(Renderer2);
private tooltip?: HTMLElement;
private tooltipTimer?: ReturnType<typeof setTimeout>;
constructor() {
const element = this.elementRef.nativeElement;
this.renderer.setStyle(element, 'transition', 'background-color 180ms ease');
if (getComputedStyle(element).position === 'static') {
this.renderer.setStyle(element, 'position', 'relative');
}
this.renderer.setStyle(element, 'cursor', 'pointer');
}
@HostListener('mouseenter')
onMouseEnter(): void {
this.renderer.setStyle(
this.elementRef.nativeElement,
'background-color',
this.highlightColor,
);
}
@HostListener('mouseleave')
onMouseLeave(): void {
this.renderer.removeStyle(
this.elementRef.nativeElement,
'background-color',
);
}
@HostListener('click')
async onClick(): Promise<void> {
const text = this.copyText?.trim() || this.elementRef.nativeElement.innerText;
if (!text.trim()) {
return;
}
try {
await navigator.clipboard.writeText(text);
this.showTooltip('복사됨!');
} catch {
this.showTooltip('복사 실패');
}
}
private showTooltip(message: string): void {
this.removeTooltip();
const tooltip = this.renderer.createElement('span') as HTMLElement;
this.tooltip = tooltip;
this.renderer.setProperty(tooltip, 'textContent', message);
this.renderer.setAttribute(tooltip, 'role', 'status');
this.renderer.setAttribute(tooltip, 'aria-live', 'polite');
this.renderer.setStyle(tooltip, 'position', 'absolute');
this.renderer.setStyle(tooltip, 'top', '100%');
this.renderer.setStyle(tooltip, 'left', '50%');
this.renderer.setStyle(tooltip, 'transform', 'translateX(-50%)');
this.renderer.setStyle(tooltip, 'margin-top', '6px');
this.renderer.setStyle(tooltip, 'padding', '4px 8px');
this.renderer.setStyle(tooltip, 'border-radius', '4px');
this.renderer.setStyle(tooltip, 'background-color', '#1f2937');
this.renderer.setStyle(tooltip, 'color', '#fff');
this.renderer.setStyle(tooltip, 'font-size', '12px');
this.renderer.setStyle(tooltip, 'white-space', 'nowrap');
this.renderer.setStyle(tooltip, 'z-index', '1000');
this.renderer.setStyle(tooltip, 'pointer-events', 'none');
this.renderer.appendChild(this.elementRef.nativeElement, tooltip);
this.tooltipTimer = setTimeout(() => {
this.removeTooltip();
}, 1500);
}
private removeTooltip(): void {
if (this.tooltip) {
this.renderer.removeChild(
this.elementRef.nativeElement,
this.tooltip,
);
this.tooltip = undefined;
}
if (this.tooltipTimer) {
clearTimeout(this.tooltipTimer);
this.tooltipTimer = undefined;
}
}
}
사용 예시:
import { Component } from '@angular/core';
import { CopyHighlightDirective } from './copy-highlight.directive';
@Component({
selector: 'app-example',
standalone: true,
imports: [CopyHighlightDirective],
template: `
<p
appCopyHighlight
highlightColor="#bfdbfe"
>
이 문장을 클릭하면 복사됩니다.
</p>
<button
appCopyHighlight
[copyText]="'버튼 클릭으로 복사되는 별도 텍스트'"
highlightColor="#bbf7d0"
>
텍스트 복사
</button>
`,
})
export class ExampleComponent {}
마우스를 올리면 background-color가 부드럽게 변경되고, 클릭하면 copyText 값을 클립보드에 복사합니다. copyText가 없으면 호스트 요소의 innerText를 사용하며, 복사 후 1.5초 동안 복사됨! 툴팁을 표시합니다.
| 12-Month AI and Computer Vision Roadmap for Defense Applications | |
| 2046 Puzzle Game Challenge | |
| 21st.dev component prompt | |
| 3D FACTORY | |
| 3D FPS Game |