我收到一条错误消息,上面写着ERROR TypeError: Cannot read property 'value' of undefined.
我正在使用Angular CLI,Typescript和HTML-Table。我检查了代码,但我不认为它是由错别字引起的。任何人都可以帮我解决这个错误吗?
//function in typescript
updStudent(newName: string, newYear: string, newSemester: string, newScore: string) {
this.stockService.updStudent(this.selectedStudent.id, newName, newYear, newSemester, newScore).subscribe;
}
loadStu(Student: any) {
this.updateEnable = true;
this.selectedStudent = Student;
}
<!--button-->
<button type="button" (click)="loadStu(Student)">UPDATE</button>
<hr>
<!--form-->
<div *ngIf="updateEnable">
id: <input disabled [value]="selectedStudent.id" />
<br>name: <input name="name" #updName [value]="selectedStudent.name" />
<br>year: <input name="year" #updYear [value]="selectedStudent.year" />
<br>semester: <input name="semester" #updSemester [value]="selectedStudent.semester" />
<br>score: <input name="score" #updScore [value]="selectedStudent.score" />
<br><button type="button" (click)="updStudent(updName.value, updYear.value, updSemester.value, UpdScore.value)">SAVE</button>
</div>
如果需要更多代码段,请告诉我。
谢谢。
答案 0 :(得分:1)
它的拼写错误,请更改
UpdScore.value
要
updScore.value