How to access parent model from polymer component

前端 未结 2 1919
闹比i
闹比i 2021-01-13 11:57

I have my-app as main application component in index.html file and uses model.dart as its model which is my application model.

my-app has my-component as its content

2条回答
  •  轮回少年
    2021-01-13 12:24

    Dart Polymer >= 1.0.0-x new PolymerDom(this).parentNode

    See also https://www.polymer-project.org/1.0/docs/devguide/local-dom.html

    Dart Polymer <= 0.16.x

    @ShailenTuli is right about encapsulation should not be broken.

    But also JS Polymer elements access the parent in their layout elements because it's still convenient in some scenarios.

    This works now in PolymerDart too.

    (this.parentNode as ShadowRoot).host
    

提交回复
热议问题