財產「符號」我有具有FormBuilder
形式的頁面組件:NativeScript /角 - 類型錯誤:無法讀取的不確定
public adForm: FormGroup = this.fb.group({
questions: this.fb.array([])
});
我通過questions
下降到<questions>
組件:
<questions [questions]="adForm.get('questions')"></questions>
其中有一個@Input() questions: FormArray;
,並使用這個模板:
<StackLayout orientation="vertical">
<!-- If I comment out listview then it doesn't throw the error -->
<ListView [items]="questions">
<ng-template let-question="item">
<Label [text]="question.model"></Label>
</ng-template>
</ListView>
<Button class="btn btn-md btn-primary" text="Add question" (tap)="addQuestion()"></Button>
</StackLayout>
我面臨的問題是,ListView
位引發此錯誤:
TypeError: Cannot read property 'Symbol' of undefined
如果我評論說,部分出來那麼它不會引發錯誤。
我知道它與questions
表單數組有關,但我一直無法弄清楚什麼。它是這樣定義的,所以它不應該成爲undefined
而不是空陣列的問題。
請注意,此錯誤直接在組件init上引發。我在ngOnInit
中記錄了questions
,它不是未定義的。
我在做什麼錯?
的感謝!在閱讀完之後我檢查,看看是否我其實是遍歷數組,但數組實際上是隱藏的更深一層 –
@BartvandenBurg很高興它幫助你:) – Chrillewoodz