0
我有一個平均APP。我有給我從MongoDB中的對象服務: 控制檯顯示:對象中的數組無法訪問打印稿
這是代碼:
塊引用
export class AllocatViewComponent implements OnInit {
equipment;
constructor(
private location: Location,
private activatedRoute: ActivatedRoute,
private router: Router,
private equipmentService: EquipmentService,
) { }
@ViewChild('myModal')
modal: BsModalComponent;
@ViewChild('deleteModal')
modal2: BsModalComponent;
ngOnInit() {
this.equipmentService.getOneById(this.currentUrl.id).subscribe(data => {
// Check if GET request was success or not
if (!data.success) {
this.messageClass = 'alert alert-danger'; // Set bootstrap error class
this.message = data.message; // Set error message
} else {
this.equipment =data.equipment;
console.log(this.equipment) // log that i share
}
});
}
save(form){
var port = {
numberPort: this.portToEdit.numberPort,
connector: "",
speedCircuit: "",
status: "Available",
function: "",
serviceType: "",
network: "",
connectedTo: "",
customerName: "",
addressCustomer: "",
lelisID: form.controls.lelisID.value,
requester: "",
dateRequester: Date,
carrier: ""
}
this.modal.close();
}
}
我怎樣才能訪問this.equipment.cards [「x」]。ports [「y」]。狀態 我試過但是:[ts]屬性'卡'沒有xist on type'{}'
謝謝!
你應該可以用'this.equiment [「property」]'來訪問它嗎? –