對我來說,最好的辦法是:
- 與創建項目
ng new
- 安裝靴子在
.angular-cli.json
附加陷阱,jQuery和字體真棒與npm install [email protected] jquery font-awesome
:
"apps": [{ "styles": [ "styles.css", "../node_modules/bootstrap/dist/css/bootstrap.min.css", "../node_modules/font-awesome/css/font-awesome.min.css" ], "scripts": [ "../node_modules/jquery/dist/jquery.min.js", "../node_modules/bootstrap/dist/js/bootstrap.min.js" ]
這將自動編譯引導CSS和JavaScript,字體真棒和jQuery,這是必需的引導js,在你的index.html中。
注意:在腳本的jquery.min.js
必須包含在bootstrap.min.js
包括前,因爲bootstrap.min.js
需要jquery.min.js
正常工作。
更新: Bootstrap 4需要tether.js。使用npm install tether
安裝它,並在bootstrap.min.js之前將其添加到.angular-cli.json
的腳本中。
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/tether/dist/js/tether.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
您好,感謝回答,我用自己的方式,但NG服務後,我看到的錯誤在我的鉻控制檯說:引導提示需要特瑟 – Adnan
我更新了我的答案。 –