【发布时间】:2022-01-12 08:43:30
【问题描述】:
在调用 setAssignment 函数的复选框中动态传递 empId 但在控制台中显示 this.empId 未定义如何解决它
<p>Manage Team for this course</p>
<div class="modal-body">
<input type="text" placeholder="Search employee" [(ngModel)]="searchText"
(input)="search()" class="mr-2 mb-2"/>
<span> <strong> Expected EndDate: </strong> </span><input type="date"/>
<div *ngFor="let employee of employeeList.sortedList index as i">
<div class="d-flex flex-row justify-content-between mt-3">
<div class="col-6">
<h5>{{employee.fullName}}</h5>
<h6>{{employee.designation}}</h6>
</div>
<div class="col-2">
<i class="far fa-calendar fa-3x"></i>
</div>
<div class="col-2 mt-2">
<input type="checkbox" checked id="checkbox" (click) ="setAssignment(i)" />
</div>
</div>
</div>
<div class="d-flex flex-row justify-content-end">
<button type="button" class="btn btn-primary " >
Assign to
</button>
</div>
</div>
在ts文件中
setAssignment(empId:Number){
console.log(this.empId)
}
【问题讨论】:
标签: angular typescript angular-directive