是否有一种方法可以访问实现ControlValueAccessor的组件中的主机?
通过主机,我了解使用了我的组件的范围。如果将其定义为< my-component>
,则在某个地方使用的地方:
< my-component name =“ test” class =“ test-class”#test =“ test-class”#test =“ ngmodel” [(ngmodel)] =“ data.test”必需>
,然后我想:
- 知道是否将主机组件应用于其上。
- 获取所有应用于NGMODEL的验证器(IE RueldsValidator)
- 知道NGModel属于的表格是否已出于
某种原因提交(不引入自己的自定义属性),我无法可靠地获得。我知道:
- 主机点,但这仅是一种方式,并且可以在主机上应用类,但没有对已经有哪些类已经有
- 元素注入的类别进行更新,我可以在这里进行本地元素和道具。这给了我课程(但水平非常低),但没有验证器 / ngmodel。
这里不允许在主机元素上访问NGMODEL“上面”?
By host, I understand the scope of where my component is used. If it is defined as <my-component>
, then if it’s used somewhere as:
<my-component name=“Test” class=“test-class” #test=“ngModel” [(ngModel)]=“data.test” required>
then I would like to:
- know if host component has a certain css class (i.e. test-class) applied to it.
- get all the validators that are applied to the ngModel there (i.e. RequiredValidator)
- know if form that ngModel belongs to has been submitted (without introducing own custom property)
For some reason, I couldn’t get to it reliably. I know of:
- HostBinding, but that is sadly one way only and can apply classes on host, but is not updated with regards to what classes already are there
- ElementRef injection, where I can get to nativeElement and props. That gives me classes (but very low level), but not validators / ngModel.
Is the access to ngModel “above” on the host element not allowed here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论