TypeScript error in Angular2 code: Cannot find name 'module'

前端 未结 11 1443
梦毁少年i
梦毁少年i 2020-11-30 03:13

I have defined the following Angular2 component:

import {Component} from \'angular2/core\';

@Component({
  selector: \'my-app\',
  moduleId: module.id,
  te         


        
11条回答
  •  没有蜡笔的小新
    2020-11-30 03:18

    I hit this error when porting my @angular/angular2 Quickstart project into a new angular cli auto-generated project.

    It seems that moduleId: module.id isn't needed anymore.

    This is the latest auto-generated component:

    import { Component } from '@angular/core';
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'app works!';
    }
    

    Removing all occurances resolved my errors.

提交回复
热议问题