Angular2未处理的承诺拒绝:模板解析错误: [英] Angular2 Unhandled Promise rejection: Template parse errors:
本文介绍了Angular2未处理的承诺拒绝:模板解析错误:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Angular2的新手,并创建了一个基本应用程序.但是当我运行应用程序时,会出现一些错误.
I am new with Angular2 and creating one basic application. But When I run application it gives some error.
这是我正在研究的unk子的链接: https://plnkr.co/edit/vnnVJtA7HJS740tvslEI?p=preview
Here is the link of plunker I am working on: https://plnkr.co/edit/vnnVJtA7HJS740tvslEI?p=preview
请提供解决方案,以便我可以从Angular2开始.以下是错误信息:
Please provide me the solution so that I can start with Angular2.Following is the error:
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>"): App@3: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>"): App@3: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/zone.js@0.6.26/dist/zone.js:232:26)
at Zone.run (https://unpkg.com/zone.js@0.6.26/dist/zone.js:114:43)
at https://unpkg.com/zone.js@0.6.26/dist/zone.js:502:57
at ZoneDelegate.invokeTask
(https://unpkg.com/zone.js@0.6.26/dist/zone.js:265:35)
at Zone.runTask
(https://unpkg.com/zone.js@0.6.26/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:(…)
推荐答案
您需要进行两项更改,
1).删除了 指令:[CourseComponent]
和
1). removed directives:[CourseComponent]
and
declarations: [ App,CourseComponent ] //#### added CourseComponent here
2)将 #
更改为 let
键盘输入
2) changed #
to let
keywork
<li *ngFor="let course of courses">
DEMO: https://plnkr.co/edit/U42S7joZT7wMCr1oBF9h?p=preview
这篇关于Angular2未处理的承诺拒绝:模板解析错误:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文