我很困惑,因为我能够从html文件中调用组件中的公共变量 -时间线过滤器组件
但是,当我尝试从另一个组件(engagement-filter.component)调用它时,它以未定义的形式返回!
有效的HTML:
time-line-filters.html:
#productFilter
[label]="'Filter on Engagement Types' | translate"
[searchPlaceholder]="'Search...' | translate"
[items]="timelineHelper.products" THIS IS WHAT IM LOOKING AT.
(filterUpdate)="filter($event)">
</tl-checkbox-group>
javascript(time-line-filters.html):
import { EngagementTimeline } from './../../../utils/engagement-
export class TimelineFilterComponent implements OnInit {
@Input() timelineHelper: EngagementTimeline;
}
用于输入的EngagementTimeline类:
export class EngagementTimeline {
public products: EngagementProduct[] = []; BEING CALLED
}
上面的方法有效,现在当我尝试对我的engagement-filter.html执行相同操作时,我无法读取未定义的产品。
<tl-checkbox-group *ngIf="this.engagementService.potentialEngagements"
#productFilter
[label]="'Engagement Types' | translate"
[searchPlaceholder]="'Search...' | translate"
[items]="timelineHelper.products" ---> Exactly the same here
[fullscreen]="false"
(filterUpdate)="updateIndividuals($event)">
JS(engagement-filter.component
import { EngagementTimeline } from './../../../utils/engagement-timeline';
export class EngagementFilterComponent implements OnInit {
@Input() timelineHelper: EngagementTimeline;
}
我缺少明显的东西吗?
任何帮助将不胜感激,谢谢!