我想尝试使用angular-cli(https://github.com/angular/angular-cli)创建Angular 2应用,然后使用ng2-material(https://github.com/justindujardin/ng2-material)用于UI组件。但是我只是不明白如何/在哪里必须包含ng2-material库才能使用它。
我使用创建了一个项目,ng new myproject
然后使用启动服务器ng serve
并打开了运行良好的网页。下一步,我使用安装了ng2-material npm install ng2-material --save
。然后我将其添加MATERIAL_PROVIDERS
到angular的引导程序,如下所示:https://github.com/AngularShowcase/angular2-seed-ng2-material/blob/master/app/bootstrap.ts。
这会在GET http://localhost:4200/ng2-material/all 404 (Not Found)
网络浏览器中产生一条错误消息,而我只是想不出如何摆脱它。
angular-cli似乎正在做一些创建dist
-folder的工作,其中index.html中使用的某些节点模块最终出现在其中,但是我看不到它的配置位置或方式。
[EDIT 29/09/2016]既然angular-cli使用的是webpack iso system.js,那么这个答案就不再有意义了。检查angular-cli Wiki上的页面“ 3d party lib安装”和“ global lib安装”。
[EDIT 10/05/2016]现在在angular cli wiki上对此进行了详细描述。
这为我工作:
在ember-cli-build.js中,将依赖项添加到vendorNpmFiles中,例如
module.exports = function (defaults) {
var app = new Angular2App(defaults, {
vendorNpmFiles: [
'a2-in-memory-web-api/web-api.js'
]
});
return app.toTree();
}
(其中a2-in-memory-web-api / web-api.js是我的node_modules文件夹中的文件)
在index.html中,添加以下行:
<script src="vendor/a2-in-memory-web-api/web-api.js"></script>
最后,您重新启动服务器。
尚未使用角形材料对其进行测试,但是您明白了。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句