angular-directives

Design reusable Angular attribute, structural, and host directives for DOM behavior.

713|170|Updated Dec 22, 2020
One-click install
npx skills add https://github.com/huajian123/ng-antd-admin --skill angular-directives-huajian123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: angular-directives
Source: https://github.com/huajian123/ng-antd-admin/tree/main/ui/.agents/skills/angular-directives
Command: npx skills add https://github.com/huajian123/ng-antd-admin --skill angular-directives-huajian123

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Create and reuse custom Angular directives (attribute, structural, and host) to extend DOM behavior and composition without relying on ad-hoc patterns or heavy NgModule boilerplate.

Core Features & Use Cases

  • Attribute directives for element-level behavior customization (style, interaction, or state).
  • Structural directives for portals and overlays, enabling dynamic DOM composition.
  • Host directives for composing multiple behaviors on a single element and sharing logic across components.

Quick Start

Create a simple directive (for example appHighlight) and apply it to an element in a component template to observe how behavior is extended without additional module wiring.

Frequently Asked Questions about angular-directives

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create reusable Angular directives to extend DOM behavior?

You create reusable Angular directives by using attribute, structural, or host directives to encapsulate element behavior and composition without heavy NgModule boilerplate. This delivers a clean API with inputs, outputs, and host metadata.

What is the difference between attribute and structural directives in Angular?

Attribute directives customize element-level behavior like style or interaction state, while structural directives enable dynamic DOM composition for patterns such as portals and overlays. Both allow you to extend DOM behavior without custom structural constructs.

How do host directives work for composing multiple behaviors in Angular 20+?

Host directives in Angular 20+ compose multiple behaviors on a single element and share logic across components. They provide a directive API surface with host metadata, enabling portable DOM behaviors without custom structural constructs.

Can I use Angular structural directives for portals and overlays?

Yes, Angular structural directives support portals and overlays by enabling dynamic DOM composition. This approach delivers portable DOM behaviors and practical portal patterns without relying on ad-hoc implementation patterns.

Do I need NgModule boilerplate to build custom Angular directives?

No, you do not need heavy NgModule boilerplate to build custom Angular directives. You can design and reuse attribute, structural, and host directives to extend DOM behavior directly without additional module wiring.

What's the best way to share directive logic across multiple Angular components?

The best way to share directive logic across Angular components is using host directives to compose multiple behaviors on a single element. This enables cross-component directive composition and delivers portable, composable DOM behaviors.