简体   繁体   中英

Cannot find the module Angular2 Typescript

My vscode shows error in the line Cannot find the module and highlights CreateTaskComponent line of app.module.ts

My code

app.module.ts

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

import { AppComponent }  from './app.component';
import { CreateTaskComponent} from './app/taskList/create-task.component';
@NgModule({
  imports: [ BrowserModule ],
  declarations: [ AppComponent, CreateTaskComponent ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

create-task.component.ts

import {Component} from '@angular/core';
@Component({
    selector:'create-task',
    templateUrl: 'app/taskList/create-task.component.html'

})
export class CreateTaskComponent{
        pageTitle : string ='Create a Task';

}

Folder structure is

在此处输入图片说明

As your app.module already there in app folder, you can directly navigate through taskList folder.

import { CreateTaskComponent} from './taskList/create-task.component';

OR

import { CreateTaskComponent} from './../app/taskList/create-task.component';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM