Angular指令覆盖指令
创始人
2024-10-30 22:30:52
0次

在Angular中,指令覆盖指令的解决方法有两种:使用@Directive()装饰器的{​​​​​​​provideIn: 'root'}选项和使用{​​​​​​​provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MyCustomControlDirective), multi: true}选项。

下面是两种解决方法的代码示例:

  1. 使用@Directive()装饰器的{​​​​​​​provideIn: 'root'}选项:
import {​​​​​​​ Directive }​​​​​​​ from '@angular/core';

@Directive({​​​​​​​
  selector: '[appMyCustomDirective]',
  provideIn: 'root'
}​​​​​​​)
export class MyCustomDirective {​​​​​​​
  // 指令逻辑...
}​​​​​​​
  1. 使用{​​​​​​​provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MyCustomControlDirective), multi: true}选项:
import {​​​​​​​ Directive, forwardRef }​​​​​​​ from '@angular/core';
import {​​​​​​​ NG_VALUE_ACCESSOR }​​​​​​​ from '@angular/forms';

@Directive({​​​​​​​
  selector: '[appMyCustomControl]',
  providers: [
    {​​​​​​​ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MyCustomControlDirective), multi: true }
  ]
}​​​​​​​)
export class MyCustomControlDirective {​​​​​​​
  // 指令逻辑...
}​​​​​​​

这两种方法都可以用来解决指令覆盖指令的问题,具体使用哪种方法取决于你的需求和场景。

相关内容

热门资讯

WPK俱乐部方案!hhpoke... WPK俱乐部方案!hhpoker辅助软件下载,德州微扑克确实存在有透视技巧1、不需要AI权限,帮助你...
WPK有透视法子!we-pok... WPK有透视法子!we-poker辅助器,德州微扑克一直真的有辅助插件1、we-poker辅助器有没...
WPK官网要领!wepoker... WPK官网要领!wepoker公共底牌,德州微扑克其实是真的有透视脚本wepoker公共底牌脚本下载...
WPK俱乐部绝活!wepoke... WPK俱乐部绝活!wepoker有辅助功能吗,德州微扑克一贯是有开挂软件1、wepoker有辅助功能...
WPK多开绝活儿!wejoke... 您好,wejoker免费脚本这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】...
WPK德州局教材!wepoke... WPK德州局教材!wepoker有辅助功能吗,德州微扑克好像真的是有辅助软件所有人都在同一条线上,像...
WPK购买烘培!aapoker... WPK购买烘培!aapoker透视插件下载,德州微扑克确实存在有辅助软件1、任何aapoker透视插...
WPK安装阶段!wepoker... WPK安装阶段!wepoker透视脚本免费,德州微扑克本来是真的有辅助器软件1、金币登录送、破产送、...
WPK安装模板!wepoker... WPK安装模板!wepoker怎么看牌型,德州微扑克其实是真的有透视挂攻略进入游戏-大厅左侧-新手福...
WPK靠谱绝活!wepoker... WPK靠谱绝活!wepoker辅助透视软件,德州微扑克一贯有透视教程运wepoker辅助透视软件辅助...