如何从使用它的不同组件中访问自定义角度飞镖组件?

时间:2016-04-13 15:47:11

标签: dart angular-dart dart-html

有没有办法访问其他组件的dart文件中使用的组件?

Component1.dart

@Component(
    selector: 'comp1',
    templateUrl: 'packages/comp1_package/Component1.html',
    cssUrl: 'packages/comp1_package/Component1.css',
    useShadowDom: false)
class Component1 {
  Component1 get comp1ctrl => this;

  Component1()  {

  }

  void testing() {
      // WANT TO CALL COMP2 printTest HERE
  }
}

Component1.html

<div id="mainTab" class="maincontainer">
    <comp2></comp2>
</div>

Component2.dart

@Component(
    selector: 'comp2',
    templateUrl: 'packages/comp2_package/Component2.html',
    cssUrl: 'packages/comp2_package/Component2.css',
    useShadowDom: false)
class Component2 {
  Component2 get comp2ctrl => this;

  Component2()  {

  }

  void printTest() {
      print("PRINTING FROM IN COMP2");
  }
}

Component2.html

<h3>TEST HEADER</h3>

如何访问Component1.dart中的Component2对象并能够调用其中的方法?任何帮助将不胜感激!

0 个答案:

没有答案