ViewChild - 在Angular 2 RC 1 JavaScript中不起作用

时间:2016-05-17 22:55:35

标签: angular angular2-routing angular2-directives angular2-services angular2-components

ViewChild并没有考虑使用Angular 2 RC 1 JavaScript。我使用过<router-outlet>。任何人都可以帮我解决这个问题吗?提前致谢。以下是我的示例代码

app.AppComponent = ng.core.
  Component({
    selector: "app", 
    template:
     '<div>' +
     '  <router-outlet></router-outlet>' +
     '  <div (click)="submit()">Submit</div>' +
     '</div>',
  queries: { 'viewChild1Component': new ng.core.ViewChild(app.Child1Component) },
  directives: [ng.router.ROUTER_DIRECTIVES]
})
.Class({
  submit: function() {
    console.log('#### submit');
    this.viewChild1Component.onSubmit();
  }
});

ng.router
        .Routes([
          { path: '/child1', component: app.Child1Component, useAsDefault: true },
        ])(app.AppComponent);

0 个答案:

没有答案