-1
剛剛接觸angularjs。請看看我的代碼甚至不能知道該如何解釋這一Angularjs 2嵌套接口
接口
export interface ScanuploadInterface {
docVia string;customFields:Array<any>;
associateDocs :Array<any>;
}
模式:
import {ScanuploadInterface} from '../../interfaces/scanupload.interface';
holeDocument = <ScanuploadInterface>{};
HTML:做* ngFor動態輸入字段
<input id="{{list.fieldName}}" name="{{list.fieldName}}" type="{{list.fieldType}}" class="form-control" [(ngModel)]="holeDocument.customFields[list.fieldName]" >
但是這一次拋出一個錯誤的
無法讀取的不確定財產 'field12'
field12是一個動態的價值來自list.fieldName。 我不知道如何解決這個問題。任何類型的解決方案,讚賞。提前致謝。
你在哪裏初始化你的customFields?它說holeDocument.customFields在我的接口未定義 –
,看到我的接口頭2號線,並在模型進口看第一行。@ AliBaig – sibi
這只是申報,不會初始化。據我所見,你還沒有分配任何使用=運算符的customFields。 –