I am trying to iterate over employeeList and display its data. This is the ts file.::
import { Component, OnInit } from '@angular/core';
import { Employee } from '../Employee';
@Component({
selector: 'app-employee-list',
templateUrl: './employee-list.component.html',
styleUrls: ['./employee-list.component.css']
})
export class EmployeeListComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
employeeList:Employee[]=
[
{
id:1,
name:"abc def",
salary:20000,
permanent:true,
department:{id:1, name:"Payroll"},
skill:[{id:1 , value:"HTML"},{id:2 , value:"CSS"},{id:1 , value:"JS"}],
dateOfBirth:new Date('01/03/2002')
},
{
id:1,
name:"ssss gggg",
salary:40000,
permanent:false,
department:{id:2, name:"Internal"},
skill:[{id:1 , value:"HTML"},{id:2 , value:"CSS"},{id:1 , value:"JS"}],
dateOfBirth:new Date('21/03/2006')
},
{
id:1,
name:"asdf zxcv",
salary:60000,
permanent:true,
department:{id:3, name:"HR"},
skill:[{id:1 , value:"HTML"},{id:2 , value:"CSS"},{id:1 , value:"JS"}],
dateOfBirth:new Date('16/05/2010')
}
];
}
This is the interface I am implementing:
export interface Employee{
id:number;
name:string;
salary:number;
permanent:boolean;
department:{id:number,name:string};
skill:[{id:number,value:string},{id:number,value:string},{id:number,value:string}];
dateOfBirth:Date
}
And this is my html file in which I display the data:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<b>Employees List</b>
<br>
<br>
<div>
<label for="search">Search</label>
<input type="text" id="search" placeholder="Find by name">
</div>
*ngFor="let e in employeeList"
<b>{{e.name}}</b>
<b>{{e.salary}}</b>
</body>
</html>
I am getting an error which says :
Property 'e' does not exist on type 'EmployeeListComponent'.
21 {{e.name}}
What am I doing wrong??