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