Wira Xie
Wira Xie

Reputation: 839

Cannot read property 'value' of undefined in

I got an Error message that says ERROR TypeError: Cannot read property 'value' of undefined. I'm using Angular CLI, Typescript, and HTML-Table. I checked the codes but i do not think it causes by typos. Can anyone help me with this error?

//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>

Please let me know if more snippets are needed.

Thank you.

Upvotes: 0

Views: 2428

Answers (1)

Vivek Doshi
Vivek Doshi

Reputation: 58533

Its typo , please change

UpdScore.value

To

updScore.value

Upvotes: 1

Related Questions