[英]How to reference a polymer component from inside an Angular.Dart component
I'm hoping someone can steer me on the right direction. 我希望有人可以引导我朝正确的方向发展。 I embedded a polymer component inside an Angular component. 我将聚合物组件嵌入了Angular组件中。 I would like to call a method from this polymer component from the angular component class. 我想从角度组件类的聚合物组件中调用一个方法。 Is this possible, if yes how would you go about doing this? 如果可能的话,这有可能吗? querySelector has not proven successful. querySelector尚未证明成功。
ang_comp.html: ang_comp.html:
<div id='ilovePolymer'>
<bwu-grid id='polymerGrid'></bwu-grid>
</div>
ang_comp.dart: ang_comp.dart:
@Component(selector: 'ang-comp', templateUrl:'ang_comp.html')
class AngularComp {
......//All the goodness
querySelector('#ilovePolymer') returns me null here.
querySelector('ang-comp').shadowRoot returns nothing
querySelector('bwu-grid') returns nothing.
I'm using Angular 1.0.0, Polymer 0.15.1+5 我正在使用Angular 1.0.0,Polymer 0.15.1 + 5
Thank you Ozan. 谢谢奥赞 That was a good suggestion, here is how I fixed it: 这是一个很好的建议,这是我的解决方法:
useShadowDom: true
to the component properties. 确保将useShadowDom: true
添加到组件属性。 shadowRootAware
Angular组件类实现了shadowRootAware
onShadowRoot
with the @override
meta. 用@override
meta覆盖onShadowRoot
。 My example class: 我的示例课:
@Component(selector: 'ang-comp', templateUrl:'ang_comp.html', useShadowRoot: true)
class AngularComp implements ShadowRootAware {
@Component(selector: 'ang-comp', templateUrl:'ang_comp.html', useShadowRoot: true)
class AngularComp implements ShadowRootAware {
... //some other stuff...
@override
onShadowRoot(ShadowRoot sr){
print(sr.querySelector('#polymerGrid') is bwu-grid); //This returns True! Yey!!
}
}
By the way, your could also use AttachAware
if you want to capture something during attach
. 顺便说一句,如果您想在attach
期间捕获某些内容,也可以使用AttachAware
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.