Angular 独立指令代码生成
根据指令类型、输入属性和宿主元素行为,生成适用于 Angular 17+ 的代码、用例及说明。
完整提示词
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.可替换内容
- [structural | attribute]
- [e.g. appHighlight, *appIf]
- [list any @Input() properties]
分类与标签
编程开发、Angular、TypeScript、指令生成、前端开发