2016-10-27 4 views
0

중첩 된 구성 요소를 사용하고 싶습니다. 이 좋은 튜토리얼 쇼, 내가 할 수있는 방법 있음 :angular2 중첩 된 구성 요소 templateUrl을 찾을 수 없습니다.

내 문제가 중첩 된 구성 요소에 대한 내 템플릿을 찾을 수 없습니다 것을
https://www.themarketingtechnologist.co/building-nested-components-in-angular-2/ 

: 내가 내가

template: '<h2>HALLO</h2>' 

시도해야하지만 싶습니다 통근 파일을 사용하여이 같은 task.component.html :

template: 'file.component.html' 

출력은, 단순히

task.component.html

는 을 표시되며 내가하려고하면

templateUrl: 'file.component.html' 

내가 얻을 오류 :

ChildComponent :

@Component({ 

    selector: 'edit-task', 
    templateUrl: 'file.component.html' 

}) 
export class FileFormat{} 
다음

Uncaught (in promise): Failed to load task.component.html

내 코드입니다

parentComponent에 :

@Component({ 
    moduleId: module.id, 
    selector: 'my-app', 
    templateUrl: 'app.template.html', 
    directives: [FileFormat] 
}) 
export class FileFormat{} 

답변

1

시도

@Component({ 
    moduleId: module.id 
    selector: 'edit-task', 
    templateUrl: 'file.component.html' 

}) 
export class FileFormat{} 

실제로 문제가 제대로 경로를받지 못하고있다 각진이 코드는 상대 경로 사용을 사용하는 moduleID

또는 하나의 전체 경로를 제공 telplateUrl 루트에서

+1

그게 .... 내가 잊어 버린 설정 : 'moduleId : module.id' –

관련 문제