Wait for dom ready without useShadowDom

前提是你 提交于 2019-12-14 04:04:06

问题


I want to wait until my component is fully loaded. The current approach would be to implement the ShadowRootAware interface. However this does not work, if the component disables the use of shadow dom:

@Component(
    selector: 'travel-step',
    templateUrl: 'packages/TravelPlanner/travelstep/travel_step_component.html',
    useShadowDom: false,
    publishAs: 'cmp')
class TravelStepComponent extends AttachAware{

I need to disable the usage of ShadowDom, because I want to use styles from my parent object (e.g. Bootstrap). Is there another way to wait for the dom to be ready?

I want to reference a file upload input. At the moment (angular v.012) there seems to be no other way to upload a file.


回答1:


You can implement ShadowRootAware interface. For example:

class NgFreeTree implements ShadowRootAware { 
  void onShadowRoot(ShadowRoot shadowRoot) { ... }
}

It should work regardless of useShadowDom attribute.




回答2:


It does not give you the error message if you use the following signature:

void onShadowRoot(Node n) {
    HtmlElement element = n;
    ...
}


来源:https://stackoverflow.com/questions/24550516/wait-for-dom-ready-without-useshadowdom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!