ViewChild - Not working in Angular 2 RC 1 JavaScript

浪子不回头ぞ 提交于 2019-12-01 22:47:46

问题


ViewChild is not woring in Angular 2 RC 1 JavaScript. I have used <router-outlet>. Can anyone help me to solve this issue? Thanks in advance. Following is my sample code

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);

来源:https://stackoverflow.com/questions/37287510/viewchild-not-working-in-angular-2-rc-1-javascript

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