2016-10-20 7 views
4

私はAngular2で新しく1つの基本アプリケーションを作成しました。しかし、私がアプリケーションを実行すると、何らかのエラーが発生します。ここでAngular2 Unhandled Promise拒否:テンプレート解析エラー:

は、私が働いているplunkerのリンクです: https://plnkr.co/edit/vnnVJtA7HJS740tvslEI?p=preview

私はAngular2.Followingで始めることができるように私にソリューションを提供してくださいエラーです:

VM654 zone.js:388 Unhandled Promise rejection: Template parse errors: 
'courses' is not a known element: 
1. If 'courses' is an Angular component, then verify that it is part  
of this module. 
2. If 'courses' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" 
to the '@NgModule.schemas' of this component to suppress this 
message. (" 
<div> 
    <h2>Hello {{name}}</h2> 
    [ERROR ->]<courses></courses> 
    </div>"): [email protected]:6 ; Zone: <root> ; Task: Promise.then ; Value: 
Error: Template parse errors:(…) Error: Template parse errors: 
'courses' is not a known element: 
1. If 'courses' is an Angular component, then verify that it is part 
of this module. 
2. If 'courses' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" 
to the '@NgModule.schemas' of this component to suppress this 
message. (" 
<div> 
    <h2>Hello {{name}}</h2> 
    [ERROR ->]<courses></courses> 
    </div>"): [email protected]:6 
at TemplateParser.parse  
(https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:8446:21) 
at RuntimeCompiler._compileTemplate  
(https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:16824:53 
) 
at eval 
(https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:16746:85 
) 
at Set.forEach (native) 
at compile 


(https://unpkg.com/@angular/compiler/bundles/compiler.umd.js:16746:49 
) 
at ZoneDelegate.invoke 
(https://unpkg.com/[email protected]/dist/zone.js:232:26) 
at Zone.run (https://unpkg.com/[email protected]/dist/zone.js:114:43) 
at https://unpkg.com/[email protected]/dist/zone.js:502:57 
at ZoneDelegate.invokeTask 
(https://unpkg.com/[email protected]/dist/zone.js:265:35) 
at Zone.runTask 
(https://unpkg.com/[email protected]/dist/zone.js:154:47)consoleError @ 
VM654 zone.js:388_loop_1 @ VM654 zone.js:417drainMicroTaskQueue @ 
VM654 zone.js:421ZoneTask.invoke @ VM654 zone.js:339 
VM654 zone.js:390 Error: Uncaught (in promise): Error: Template parse 
errors:(…) 

答えて

9

あなたは何をする必要2つの変更、

1)。 )directives:[CourseComponent]

declarations: [ App,CourseComponent ] //#### added CourseComponent here 

2を取り外し変更#letにkeywork

<li *ngFor="let course of courses"> 

DEMO:https://plnkr.co/edit/U42S7joZT7wMCr1oBF9h?p=preview

+0

thankuはあまり..それが働いた!!!!!!。しかし、なぜ私たちがCourseComponentを宣言で宣言したのかを理解できませんでした。指示文 –

+0

指令が新しいバージョンで削除されました。したがって、宣言メタプロパティで宣言する必要があります。それが問題を解決したら、答えとしてそれを受け入れてください。 – micronyks

関連する問題