원클릭으로
angular-directive
Generates Angular directives for DOM manipulation and behavior enhancement
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Generates Angular directives for DOM manipulation and behavior enhancement
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Generates Angular animations for smooth UI transitions and interactions
Generates Angular components with best practices and patterns
Generates an Angular dialog component extending BaseDialogComponent
Generates Angular error boundary components for graceful error handling
Generates an Angular feature component (Standalone, OnPush)
Generates Angular reactive forms with validation, error handling, and state management
| name | angular-directive |
| description | Generates Angular directives for DOM manipulation and behavior enhancement |
This skill helps you generate Angular directives for DOM manipulation, behavior enhancement, and reusable functionality following Angular best practices.
import { Directive, ElementRef, Input, OnInit, OnDestroy } from '@angular/core';
@Directive({
selector: '[app{{Name}}]',
standalone: true,
})
export class {{Name}}Directive implements OnInit, OnDestroy {
@Input('app{{Name}}') config: any;
constructor(private el: ElementRef) {}
ngOnInit(): void {
// Initialize directive logic
this.applyDirective();
}
ngOnDestroy(): void {
// Clean up resources
}
private applyDirective(): void {
// Apply directive behavior
const element = this.el.nativeElement;
// Manipulate DOM or add behavior
}
}
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
@Directive({
selector: '[app{{Name}}]',
standalone: true,
})
export class {{Name}}Directive {
private hasView = false;
constructor(
private templateRef: TemplateRef<any>,
private viewContainer: ViewContainerRef
) {}
@Input() set app{{Name}}(condition: any) {
if (condition && !this.hasView) {
this.viewContainer.createEmbeddedView(this.templateRef);
this.hasView = true;
} else if (!condition && this.hasView) {
this.viewContainer.clear();
this.hasView = false;
}
}
}
import { Directive, ElementRef, Input, OnInit } from '@angular/core';
@Directive({
selector: '[appAutofocus]',
standalone: true,
})
export class AutofocusDirective implements OnInit {
@Input() appAutofocus: boolean = true;
constructor(private el: ElementRef) {}
ngOnInit(): void {
if (this.appAutofocus) {
setTimeout(() => {
this.el.nativeElement.focus();
});
}
}
}
import { Directive, ElementRef, Output, EventEmitter, HostListener } from '@angular/core';
@Directive({
selector: '[appClickOutside]',
standalone: true,
})
export class ClickOutsideDirective {
@Output() appClickOutside = new EventEmitter<void>();
constructor(private el: ElementRef) {}
@HostListener('document:click', ['$event'])
onDocumentClick(event: Event): void {
if (!this.el.nativeElement.contains(event.target)) {
this.appClickOutside.emit();
}
}
}
import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
@Directive({
selector: '[appDebounceClick]',
standalone: true,
})
export class DebounceClickDirective {
@Input() debounceTime = 300;
@Output() appDebounceClick = new EventEmitter();
private timeout: any;
@HostListener('click', ['$event'])
onClick(event: Event): void {
event.preventDefault();
event.stopPropagation();
if (this.timeout) {
clearTimeout(this.timeout);
}
this.timeout = setTimeout(() => {
this.appDebounceClick.emit(event);
}, this.debounceTime);
}
}
import { Directive, ElementRef, Input, OnInit } from '@angular/core';
@Directive({
selector: 'img[appLazyLoad]',
standalone: true,
})
export class LazyLoadDirective implements OnInit {
@Input('appLazyLoad') src: string;
constructor(private el: ElementRef<HTMLImageElement>) {}
ngOnInit(): void {
const img = this.el.nativeElement;
// Create intersection observer
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
img.src = this.src;
observer.unobserve(img);
}
});
});
observer.observe(img);
}
}
<!-- Attribute directive -->
<div [appHighlight]="color">Highlighted text</div>
<!-- Structural directive -->
<div *appUnless="condition">Content shown when condition is false</div>
<!-- Click outside -->
<div appClickOutside (appClickOutside)="closeDropdown()">...</div>
<!-- Debounce click -->
<button appDebounceClick (appDebounceClick)="handleClick()">Click me</button>
<!-- Lazy load image -->
<img appLazyLoad="image-url.jpg" alt="Lazy loaded image" />
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { {{Name}}Directive } from './{{name}}.directive';
describe('{{Name}}Directive', () => {
let fixture: ComponentFixture<TestComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [TestComponent, {{Name}}Directive],
});
fixture = TestBed.createComponent(TestComponent);
fixture.detectChanges();
});
it('should create an instance', () => {
const directive = fixture.debugElement.query(By.directive({{Name}}Directive));
expect(directive).toBeTruthy();
});
it('should apply directive behavior', () => {
// Test directive functionality
});
});
// Test component
@Component({
template: `<div app{{Name}}>Test</div>`,
standalone: true,
})
class TestComponent {}
standalone: true for modern Angular@HostListener for DOM events