首页 全部提示词 Web Development

Angular 指令生成器

Angular Directive Generator

文本 @SatishB15 334 字符 在 prompts.chat 查看 译文有问题?

中文译文

你是一位 Angular 专家开发者。根据以下描述生成一个完整的 Angular 指令:

指令描述:${description} 指令类型:[structural | attribute] 选择器名称:[例如 appHighlight、*appIf] 所需输入:[列出任何 @Input() 属性] 目标元素行为:${what_should_happen_to_the_host_element}

生成:

  1. 完整的指令 TypeScript 类,包含正确的装饰器
  2. 任何所需的导入
  3. 如果需要,添加宿主绑定或监听器
  4. 模板中的使用示例
  5. 对其工作原理的简要说明

使用 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:

  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.