我是angular 2的初学者。Angular 2项目使用npm包,我们可以通过简单地导入如下内容来在angular 2项目中使用它们
import { FormsModule } from '@angular/forms';
另外,我们可以使用package.json
file导入和安装npm软件包。
但是问题是我必须bower
在我的angular 2项目中导入组件。这是安装链接和使用指南bower component
(https://www.predix-ui.com/?show=getting_started&type=local)
我复制了凉亭的部件置入资产的文件夹在我的项目,并试图进口,在凉亭组成我的index.html
如下
<head>
<meta charset="utf-8">
<title>TestApp</title>
<base href="/">
<link rel="import" href="./assets/px-spinner/px-spinner.html" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
然后,我尝试在我的app.component.html
文件中使用它们,src/app
如下所示。
<h1>
{{title}}
</h1>
<px-spinner>
<px-inbox height="100vh" list-items='[{"id":"1","title":"GT Vibration","subtitle":"Block 2","severity":"important","date":"2016-10-05T01:29"}]'>
// define or bind to your details view here
</px-inbox>
</px-spinner>
但随后出现以下错误。
zone.js:388Unhandled Promise rejection: Template parse errors:
'px-inbox' is not a known element:
1. If 'px-inbox' is an Angular component, then verify that it is part of this module.
2. If 'px-inbox' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
</h1>
<link rel="import" href="./assets/px-spinner/px-spinner.html" />
[ERROR ->]<px-inbox height="100vh" list-items='[{"id":"1","title":"GT Vibration","subtitle":"Block 2","severity"): AppComponent@4:0 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:(…) Error: Template parse errors:
'px-inbox' is not a known element:
1. If 'px-inbox' is an Angular component, then verify that it is part of this module.
2. If 'px-inbox' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
</h1>
<link rel="import" href="./assets/px-spinner/px-spinner.html" />
[ERROR ->]<px-inbox height="100vh" list-items='[{"id":"1","title":"GT Vibration","subtitle":"Block 2","severity"): AppComponent@4:0
at TemplateParser.parse (http://127.0.0.1:4200/main.bundle.js:13787:19)
at RuntimeCompiler._compileTemplate (http://127.0.0.1:4200/main.bundle.js:32817:51)
at http://127.0.0.1:4200/main.bundle.js:32737:62
at Set.forEach (native)
at RuntimeCompiler._compileComponents (http://127.0.0.1:4200/main.bundle.js:32737:19)
at createResult (http://127.0.0.1:4200/main.bundle.js:32633:19)
at ZoneDelegate.invoke (http://127.0.0.1:4200/main.bundle.js:62681:26)
at Zone.run (http://127.0.0.1:4200/main.bundle.js:62563:43)
at http://127.0.0.1:4200/main.bundle.js:62951:57
at ZoneDelegate.invokeTask (http://127.0.0.1:4200/main.bundle.js:62714:35)
现在,我对如何在项目中使用它们感到困惑。请给我一个提示。
谢谢
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句