0
我新的角2 我有一個對象的屬性,它是地圖訪問映射屬性角2
的實例,我想訪問到它的價值。
InputFirstComponent
export class InputFirstComponent implements OnInit {
@Input() public inputFirstToDisplay: CustomInput;
constructor() { }
ngOnInit() {
console.log('InputFirstComponent: onInit');
console.log(this.inputFirstToDisplay);
console.log('attribute Object which i want to acces to its attribute')
console.log(this.inputFirstToDisplay.attributes);
}
}
我試圖
console.log(this.inputFirstToDisplay.attributes.get('minOccurs'));
console.log(this.inputFirstToDisplay.attributes['minOccurs'].value); //
print undefined
CustomInput類的對象inputFirstToDisplay :
export class CustomInput {
constructor(public name: string, public text: string, public defaultText:
string,
public complexType: boolean, public type: string, public children:
CustomInput[] = [],
public isMultiValued: boolean,
public values: string[] = [], public indicator: string, public
required: boolean,
public isSelected: boolean, public
simpleTypeVarietyOrComplexTypeContent: number,
public choiceContent: boolean, public inputQname: string,
public attributes: Map<string, string> = new Map<string, string>()
) {}
}
屬性:Map(String,string)是自定義輸入類的一個屬性,我想訪問它的值。
感謝
請鏈接引用的問題 – borislemke
謝謝,它的工作原理。事實上,我選擇使用地圖,因爲我從後端接收輸入,只是顯示它。 – adem