加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular2 Unhandled Promise rejection:模板解析错误:

发布时间:2020-12-17 06:53:33 所属栏目:安全 来源:网络整理
导读:我是Angular2的新手,并创建了一个基本的应用程序.但是,当我运行应用程序时,它会出现一些错 这是我正在研究的plunker的链接: https://plnkr.co/edit/vnnVJtA7HJS740tvslEI?p=preview 请提供解决方案,以便我可以从Angular2开始.以下是错误: VM654 zone.js:38
我是Angular2的新手,并创建了一个基本的应用程序.但是,当我运行应用程序时,它会出现一些错

这是我正在研究的plunker的链接:
https://plnkr.co/edit/vnnVJtA7HJS740tvslEI?p=preview

请提供解决方案,以便我可以从Angular2开始.以下是错误:

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]和

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

2)改变#让键盘工作

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读