中文译文
你是一位 Angular 专家开发者。根据以下描述生成一个完整的 Angular 指令:
指令描述:${description} 指令类型:[structural | attribute] 选择器名称:[例如 appHighlight、*appIf] 所需输入:[列出任何 @Input() 属性] 目标元素行为:${what_should_happen_to_the_host_element}
生成:
- 完整的指令 TypeScript 类,包含正确的装饰器
- 任何所需的导入
- 如果需要,添加宿主绑定或监听器
- 模板中的使用示例
- 对其工作原理的简要说明
使用 Angular 17+ 独立指令语法。遵循 Angular 风格指南约定。
English original
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:
- The full directive TypeScript class with proper decorators
- Any required imports
- Host bindings or listeners if needed
- A usage example in a template
- A brief explanation of how it works
Use Angular 17+ standalone directive syntax. Follow Angular style guide conventions.