angular8 - 找不到模块错误:无法在 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']);
}
}
解决方案
删除此行:
styleUrls: [' ']
或添加带有样式的文件的路径。
如果要编写内联样式,请更改styleUrls: [' ']
为styles: ''
推荐阅读
- wso2 - 是否可以使用 WSO2 身份服务器 5.10 中的数据将嵌入 h2 数据库迁移到 PostgreSQL 数据库
- javascript - 如何使用 item.description 在列表视图中选择项目
- java - 如何让骑士在棋盘中随机移动?
- python - 如何在 Python 类中使用方法而不是函数来使用 Bottle?
- python - 检查深层嵌套列表中的条件
- postcss - 如何用带有 postcss8 API `Declaration` 的正则表达式替换`walkDecls`
- java - 具有 Gson 序列化/反序列化的抽象类
- sql - 如何合并两个数据库?
- angular - 以编程方式将 PrimeNG 元素添加到 DOM
- r - 如何计算R空间中定义区域内的值?