我的目标是通过bid-filter.component (子)将位置数组从results.component(祖父)传递到destination-selector.component(父)。
results.ts(祖父母)
this.subscriptions.add(
this.customerService.getAllDestinations().subscribe(loc => {
this.locations = loc.payload;
console.log("from results",this.locations);
})
);
此处的日志已定义并显示位置数组
results.html(祖父母)
<app-bid-filter [locations]="locations" [selectedValues]="selectedValues"
(search)="toggleFilters();search($event)"></app-bid-filter>
出价过滤器.ts(父)
@Input() locations;
ngOnInit() {
this.isHome = this.router.url === '/home';
console.log(this.locations);
}
这里的日志是未定义的
出价过滤器.html(父)
app-destination-selector (selectedDestination)="selectedLocation($event)" [destinations]="locations"
[defaultDestinationId]="selectedValues?.destination"></app-destination-selector>
目的地选择器.ts(子)
@Input() destinations;
ngOnInit() {
console.log(this.destinations);
}
也显示未定义
我在这里错过了一些非常明显的东西吗?我检查了一些不适用于我的问题的解决方案Angular 2 Component @Input not working
任何帮助表示赞赏。