2017-05-09 11 views
0
정의되지 않은

의 특성 'templateRef'을 읽을 수 없습니다하지만 난이 오류를 형식 오류를 얻을 : 정의되지 않은 재산 'templateRef'을 읽을 수 없습니다 . ng-template템플릿 태그로 바꾸면 모든 것이 잘됩니다. 내가 잘못하고있는 것이 무엇입니까? 여기 코드입니다 :각도 2 NG-부트 스트랩, NgbTabset 오류 : (약속을) catch되지 않은 : 형식 오류 : 나는이 NgTabset를 사용하려고

<ngb-tabset> 
    <ngb-tab> 
    <ng-template ngbTabTitle> 
     Tab1 
    </ng-template> 
    <ng-template ngbTabContent> 
     Here is tab 1 
    </ng-template> 
    </ngb-tab> 
</ngb-tabset> 
+1

소리가 종속성 오류와 같습니다. 모듈에서 가져 오기가 누락되었거나 Angular 버전을 업데이트해야합니다. –

답변

0

그것은 Plunkr없이 알고 있지만 templateRef을 설정해야 조금 어렵다과 #

<app-content [templateRef]="nestedComponentRef"></app-content> 
<template #nestedComponentRef> 
    <component> 
    </component> 
</template> 

다음은 예입니다 : https://embed.plnkr.co/zsG5ROJD1jYVIoXaR9Ga/

0

코멘트 David Aguirre는 이것이 종속성 문제라고 제안했지만 적어도 부분적으로 ng-bootstrap 버전 때문인 것으로 보입니다.

나는이 같은 문제가 없었다 및 NG-부트 스트랩의 내 버전은 1.0.0-alpha.24 것을 발견,하지만 난 버전 있음을 인하하면 https://ng-bootstrap.github.io/app/components/tabset/demos/basic/plnkr.html의 예에서 config.js의 라인은 '@ng-bootstrap/ng-bootstrap': 'npm:@ng-bootstrap/[email protected]/bundles/ng-bootstrap.js'

했다 숫자를 1.0.0-alpha.24로 변경했습니다. 아래에 여러 오류 메시지가 있습니다. 1.0.0-alpha.28까지의 변화를 만들기

웹에서 우리의 코드의 버전에서 일하지만, VCCode 개발 환경에서 코드에서 난 그냥 변화하는 것을 발견 <template><ng-template>

"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.24", 
package.json에

"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.28", 

에이 문제를 해결하는 것만으로는 충분하지,하지만 새로운 CLI 인스턴스가 문제를 해결 만드는, 그래서 내가 찾지 못한 다른 의존성이 있어야합니다.

1.0.0-alpha.24와 https://ng-bootstrap.github.io/app/components/tabset/demos/basic/plnkr.html에서 경고했다 : 코드가 <ng-template> 아닌 경고 항에있어서, 상기 <template> 요소를 사용하기 때문에
Template parse warnings: 
The <template> element is deprecated. Use <ng-template> instead ("[WARNING ->]<template ngFor [ngForOf]="parts" let-part let-isOdd="odd"><span *ngIf="isOdd" class="{{highlightClas"): ng:///NgbTypeaheadModule/[email protected]:0 

오해의 소지가 있었다. 오류 메시지의

첫 번째 라인은 있었다 : 다른 사람들이이 메시지를받을 때

ERROR TypeError: Cannot read property 'templateRef' of undefined 

ERROR CONTEXT DebugContext_ {view: Object, nodeIndex: 3, nodeDef: Object, elDef: Object, elView: Object} 

Unhandled Promise rejection: Cannot read property 'templateRef' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'templateRef' of undefined 

Error: Uncaught (in promise): TypeError: Cannot read property 'templateRef' of undefined 

가 잘하면 그들이이 스레드를 찾을 수 있습니다.

경고 및 오류 메시지가 오도 된 것이 아니고 명확하지 않은 경우 도움이됩니다.