믿을 수 없으며 2 시간 동안 템플릿을로드 할 수 없습니다. 구글에 수치심이 아주 안좋아. 나는 이것이 매우 성가신 것을 배우고있다. 이것이 내 코드입니다.각도 2에 templateUrl을 사용할 수 없습니다.
import { Component } from '@angular/core';
@Component({
selector: 'mw-app',
templateUrl: 'app/app.component.html',
})
export class AppComponent
프로젝트 구조
--angular2-training
--app
--app.component.ts
는 의 moduleID 추가하려고 시도 : module.id, 및 tsconfig.js에게 "모듈"변경 "commonjs"을 필요로 시도
() 아무것도 도움이되지 않습니다. 정말 안됐다.
@Component({
selector: 'about',
template: require('./about.component.html'),
styles: [String(require('./about.component.scss'))]
})
더블 .. 템플릿의 경로를 확인하고 템플릿이 TS 파일의 같은 디렉토리에있는 경우에도 전에 ./ 넣어보십시오 : 당신이 웹팩이 시도 사용하는 경우 나에게
은 같은 디렉토리의 템플릿입니까? 'app', './app.component.html'이 필요하지 않습니다. – Fals
어떤 빌드 시스템을 사용합니까? 어떤 자습서를 따르십니까? –
귀하의 HTML 파일은 어디에 있습니까? – enucar