[英]require: 'ngModel' in Angular 6/7+
I'm working on a simple upper/lower case directive. 我正在研究一个简单的大写/小写指令。 Since I use ControlValueAccessor I would like to be able to require ngModel directive on a same host element where I apply my appCaseTo directive.
由于我使用ControlValueAccessor,因此我希望能够在应用appCaseTo指令的同一主机元素上要求ngModel指令。
Is there way to do that in Angular? 有没有办法在Angular中做到这一点?
How to require presence of certain directive from another directive? 如何要求另一个指令中存在某个指令?
Similar to AngularJS with require: 'ngModel'
approach. 与AngularJS相似,具有
require: 'ngModel'
方法。
return {
require: 'ngModel',
link: function (scope, element, attrs, modelCtrl) {
Stackblitz project. Stackblitz项目。
我不确定您要完成什么,但是您可以将ngModel“包括”到选择器中,如下所示:
selector: '[ngModel][appCaseTo]',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.