简体   繁体   English

Angular 6自定义元素与父DOM的交互

[英]Angular 6 custom element interaction with parent DOM

I am using angular element for javascript error reporting. 我正在使用角度元素进行JavaScript错误报告。 I am following this tutorial for error handling and reporting in the angular application. 我正在按照本教程进行有关角度应用程序中的错误处理和报告的操作。 This code is working in angular application but I want to reuse it outside the angular application. 该代码在角度应用程序中有效,但是我想在角度应用程序之外重用它。 So I have packed this code in an angular element and used as a custom element in a non-angular application. 因此,我已将此代码打包在有角度的元素中,并在非角度应用程序中用作自定义元素。 But it doesn't work. 但这是行不通的。

I think angular elements don't have the access to the scope of the page. 我认为角度元素无法访问页面范围。 But I am not sure what is the problem here, I just want to know this is possible or not, If yes what mistake I am doing. 但是我不确定这里是什么问题,我只是想知道这是否可能,如果是,我在做什么错。

Thanks. 谢谢。

To access angular elements or component, you can go through this. 要访问角度元素或组件,可以进行此操作。

https://angular.io/guide/component-interaction https://angular.io/guide/component-interaction

It allow you to access and manupulate element of another component. 它允许您访问和操纵另一个组件的元素。

If you are trying to access method from outside the source. 如果您尝试从源外部访问方法。 you should go through ngZone 您应该通过ngZone

https://angular.io/api/core/NgZone https://angular.io/api/core/NgZone

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM