2
我想在Angular2中使用@ContentChildren在嚮導中導航。 但是,當我使用它,我有這個錯誤:「zone.js?fad3:158未捕獲的錯誤:由於查詢選擇器未定義,無法爲」ExtendedWizard「的屬性」步驟「構造查詢。Angular2:ContentChildren + QueryList錯誤
wizard.component.ts
import { Component, ContentChildren, QueryList } from '@angular/core';
@Component({
selector: 'extended-wizard',
template: `
<ul>
<li *ngFor="let step of steps">
{{step.title}}
</li>
</ul>
<ng-content></ng-content>
`
})
export class ExtendedWizard {
@ContentChildren(ExtendedStep) steps: QueryList<ExtendedStep>;
}
@Component({
selector: 'extended-step',
template: `
<fieldset>
{{title}}
<ng-content></ng-content>
</fieldset>
`
})
export class ExtendedStep {
title: string;
}
app.component.html
<extended-wizard>
<extended-step title="Step 1"></extended-step>
<extended-step title="Step 2"></extended-step>
</extended-wizard>
感謝您的幫助
天啊!謝謝 – di99er