app.component.ts
viewDelete() {
console.log('s')
this.isDelete = !this.isDelete
console.log(this.isDelete);
this.viewData(id) ==>> I am getting error here id is not defined
}
viewData(id) {
console.log('comes')
this.departmentService.getDepartmentById(id).subscribe(
res => this.departmentDetail = res,
error => this.error = error
)
}
I want to call viewData() function from viewDelete() function. It is getting call correctly but argument id in viewData(id) giving error, id is not defined
idfirst of all. Since it's not inside the function so let's assume you have defined at class level, so its very basic question, how to access a class-level variable.