After Angular 2.0 final release, the structure of the Angular2 CLI project has been changed — you don't need any vendor files, no system.js — only webpack. So you do:
一百
在angular-cli.json
文件中找到styles[]
数组,并在此处添加font awesome references目录,如下所示:
"apps": [
{
"root": "src",
"outDir": "dist",
....
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.css",
"../node_modules/font-awesome/css/font-awesome.css" // -here webpack will automatically build a link css element out of this!?
],
...
}
]
],
在Angular的较新版本中,使用
angular.json
文件,而不使用../
文件.例如,使用"node_modules/font-awesome/css/font-awesome.css"
.
在任何您想要的html文件中放置一些字体令人惊叹的图标:
<i class="fa fa-american-sign-language-interpreting fa-5x" aria-hidden="true"> </i>
停止应用程序Ctrl+c,然后使用ng serve
重新运行应用程序,因为观察器仅用于src文件夹,并且不会观察angle-cli.json是否有变化.