首页 > 解决方案 > 找不到模块错误:无法在 Angular8 中解析“./”

问题描述

./src/app/list-emp/list-emp.component.ts 中的错误找不到模块:错误:无法解析 'E:​​\angular\Assignments\CrudExampleNodejs\Assign4\src\app\ 中的 './'列表-emp'

我的 list-emp.ts 如下

import { Component, OnInit } from '@angular/core';  
import { EmployeeService } from '../employee.service';  
import { Employee } from '../app.module';  
import { Router } from "@angular/router";  

@Component({  
  selector: 'app-list-emp',  
  templateUrl: './list-emp.component.html',  
  styleUrls: [' ']  
})  
export class ListEmpComponent implements OnInit {  

  employees: Employee[];  

  constructor(private empService: EmployeeService, private router: Router, ) { }  

  ngOnInit() {  
    this.empService.getEmployees()  
      .subscribe((data: Employee[]) => {  
        this.employees = data;  
      });  
  }  
  deleteEmp(employee: Employee): void {  
    this.empService.deleteEmployees(employee.id)  
      .subscribe(data => {  
        this.employees = this.employees.filter(u => u !== employee);  
      })  
  }  
  editEmp(employee: Employee): void {  
    localStorage.removeItem('editEmpId');  
    localStorage.setItem('editEmpId', employee.id.toString());  
    this.router.navigate(['add-emp']);  
  }  
}  

标签: angular8

解决方案


删除此行:

styleUrls: [' ']

或添加带有样式的文件的路径。

如果要编写内联样式,请更改styleUrls: [' ']styles: ''


推荐阅读