简体   繁体   中英

import a new angular module to my app-root

i have create a new angular module

import { Component } from '@angular/core';
import { Hero } from './hero';

@Component({
  selector: 'hero-detail',
  template: `
    <div *ngIf="hero">
      <h2>{{hero.name}} details!</h2>
      <div><label>id: </label>{{hero.id}}</div>
      <div>
        <label>name: </label>
        <input [(ngModel)]="hero.name" placeholder="name"/>
      </div>
    </div>
  `
})
export class HeroDetailComponent {
hero: Hero;
}

and i'm trying to import it in my app-root module using the import statement

import { HeroDetail } from 'hero-detail';

but i get this error "src/app/app.component.ts (2,28): Cannot find module 'hero-detail'."

这为我解决了

import { HeroDetailComponent } from './hero-detail.component';

您必须使用正确的componenet名称

import { HeroDetailComponent } from 'hero-detail';

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