나는 불쾌한을하기 시작 각도-CLI로 만든 간단한 응용 프로그램, 나는 리팩토링과 별도의 구성 요소 파일에 app.component.ts 코드를 이동하고 싶었습니다 확인할 수 없습니다 오류 :각도 2 : 모듈을 찾을 수 없습니다 오류 :
Module not found: Error: Can't resolve on './sb/sb.component.html' ( my SBComponent). Under the
이 내가 무엇을 :
app.module :
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { SBComponent } from './sb/sb.component'
@NgModule({
declarations: [
AppComponent, SBComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component :
import { Component } from '@angular/core';
import { NgModule,ElementRef, ViewChild, AfterViewInit} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
새로운 구성 요소 :
은import { Component, OnInit } from '@angular/core';
import { NgModule,ElementRef, ViewChild, AfterViewInit, AfterContentInit} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
@Component({
selector: 'app-sb',
templateUrl: './sb/sb.component.html'
})
export class SBComponent {
}
는 어떤 도움을 크게 감상 할 수있다! 구성 요소가 같은 디렉토리 내에있는 경우
sb 폴더 안에 'sb.component.html'이 있습니까? 두 폴더가 같은 폴더에 있다면이 파일을 실행하십시오. '/ sb.component.html' –
예 sb 폴더 내에 존재하고 app.ts가 해당 폴더 외부에 존재합니다. – eagleEye
은'SBComponent' 안에'templateUrl'을'templateUrl : '로 변경합니다./sb.component.html'' –