我是Angular2的新手。我试图实现接口,然后将其导入另一个组件,但我继续收到以下错误:
/app/employee/employeeList.component.ts(5,10)中的错误:模块'“/ app / employee / employee”'没有导出的成员'IEmployee'。
我确实在StackOverflow上发现了几个帖子,我确实尝试了提供的解决方案,但他们没有解决我的问题。
File1:employee.ts
export interface IEmployee {
code: string;
name: string;
gender: string;
annualSalary: number;
}
File2:employeeList.component.ts
import { IEmployee } from './employee';
import { Component } from '@angular/core';
@Component({
selector: 'app-list-employee',
templateUrl: './employeeList.component.html',
})
export class EmployeeListComponent {
employees: IEmployee[];
selectedEmployeeCountRadioButton = 'All';
constructor() {
this.employees = [
{ code: 'e1', name: 'Tom', gender: 'Male', annualSalary: 5600 },
{ code: 'e2', name: 'Sam', gender: 'Male', annualSalary: 6600 },
];
}
以下是我的文件结构: