在angular 2中找不到模块

在angular 2中找不到模块,angular,Angular,我是angular 2的新手。我创建了一个自定义组件,甚至在app.module.ts中注册了 查找我的文件夹结构: emp.component.ts: import {Component} from '@angular/core' @Component({ selector:'emp-tag', templateUrl:'./Employee/emp.component.html' }) export class EmployeeComponent { title : 'This

我是angular 2的新手。我创建了一个自定义组件,甚至在app.module.ts中注册了 查找我的文件夹结构:

emp.component.ts:

import {Component} from '@angular/core'

@Component({
selector:'emp-tag',
templateUrl:'./Employee/emp.component.html'
})
export class EmployeeComponent
{
    title : 'This is Employee Component';
}
emp.component.html:

Hai {{title}}
在app.module.ts文件中注册,如下所示:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import {EmployeeComponent} from './Employee/emp.component'

@NgModule({
  declarations: [
    AppComponent,
    EmployeeComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
当我使用ng server-open运行我的应用程序时,我面临一个编译时错误,因为在命令提示符窗口中找不到like模块,如下图所示


从我的文件夹结构来看,我在app.module.ts文件中给出了正确的路径。

只需按如下所示更改路径,因为您位于同一文件夹中

templateUrl:'。/emp.component.html

完整代码


只需按如下所示更改路径,因为您位于同一文件夹中

templateUrl:'。/emp.component.html

完整代码

emp.component.ts

使用

而不是

templateUrl:'./Employee/emp.component.html' 
emp.component.ts

使用

而不是

templateUrl:'./Employee/emp.component.html' 


是的,谢谢。您如何在不创建更改历史记录的情况下编辑您的答案?哪种编辑?除了格式化,我不能做太多的改变,因为这是我以前从未认识到的一个特性,甚至我以前也不认识它:是的,谢谢。你怎么能在不创建更改历史记录的情况下编辑你的答案?哪种编辑?我只能做很多改变,除了格式化可能是因为这是一个我以前从未认识到的功能,甚至我以前也没有认识到它:你读过错误信息吗?你读过错误信息吗?可能是因为同一个答案,我提供了一个与现有答案不同的答案。它有什么不同吗?@Sajeetharan you更新你的回答。早些时候,你发布了整个代码,我只提到了需要更改的行。好吧,这很有意义!即使我不接受,这是一个不同的答案!可能是因为同一个答案,我提供了与现有答案不同的答案。有什么不同吗?@Sajeetharan你更新了你的答案。早些时候,你发布了整个代码,我只提到了需要更改的行。好吧,这很有意义!即使我不接受,这是一个不同的答案!
templateUrl:'./Employee/emp.component.html'