我试图修改NG2课程的代码,使NG2中的动态Spotify播放器。当我将<h1>anything</h1>
添加到我的模板app.component.js中时,它可以工作。当我在+`的代码添加给这个错误Angular 2,模板错误破解简单的网站
zone.min.js:1 Unhandled Promise rejection: Template parse errors:
'spotifyiframeplayer' is not a known element:
1. If 'spotifyiframeplayer' is an Angular component, then verify that it is part of this module.
2. If 'spotifyiframeplayer' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("<h1>Spotify Iframe Player</h1>[ERROR ->]<spotifyiframeplayer></spotifyiframeplayer>"): [email protected]:30 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:(…) Error: Template parse errors:
'spotifyiframeplayer' is not a known element:
1. If 'spotifyiframeplayer' is an Angular component, then verify that it is part of this module.
2. If 'spotifyiframeplayer' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("<h1>Spotify Iframe Player</h1>[ERROR ->]<spotifyiframeplayer></spotifyiframeplayer>"): [email protected]:30
at TemplateParser.parse (https://unpkg.com/@angular/[email protected]/bundles/compiler.umd.js:8530:21)
at RuntimeCompiler._compileTemplate (https://unpkg.com/@angular/[email protected]/bundles/compiler.umd.js:16905:53)
at https://unpkg.com/@angular/[email protected]/bundles/compiler.umd.js:16828:85
at Set.forEach (native)
at compile (https://unpkg.com/@angular/[email protected]/bundles/compiler.umd.js:16828:49)
at e.invoke (https://unpkg.com/[email protected]/dist/zone.min.js:1:15936)
at n.run (https://unpkg.com/[email protected]/dist/zone.min.js:1:13323)
at https://unpkg.com/[email protected]/dist/zone.min.js:1:11425
at e.invokeTask (https://unpkg.com/[email protected]/dist/zone.min.js:1:16565)
at n.runTask (https://unpkg.com/[email protected]/dist/zone.min.js:1:13925)o @ zone.min.js:1a @ zone.min.js:1a @ zone.min.js:1
zone.min.js:1 Error: Uncaught (in promise): Error: Template parse errors:(…)o @ zone.min.js:1a @ zone.min.js:1a @ zone.min.js:1
Link to Plunker 我不知道如何解决这个问题的错误。我已经检查过,元素只在示例代码中提到过一次,并且适用于该项目。
@galvon(这也是对plunker)
(function(app) {
var Component = ng.core.Component;
app.AppComponent = Component({
selector: 'my-app',
template:
`
<h1>Spotify Iframe Player</h1>
<spotifyiframeplayer></spotifyiframeplayer>
`
})
.Class({
constructor: function AppComponent() { }
});
})(window.app || (window.app = {}));
请发布您的模板,这是无效的(语法) – galvan
你在哪里定义'spotifyiframeplayer'组件。你应该添加这个组件到''声明'属性的yout模块 – yurzui
我会尝试在app.component.js中声明 – drew4452862