How to include external css and js file in angular 6 / Angular 7

Posted at: December 3, 2018 4:25 PM

You can include css and js file in your angular project using npm command or direct insert link into src/index.html. I have described both options. I have taken example of Materialize css.

Option 1

Install Materialize css using npm command.

open angular.json and your css file path in styles: ["node_modules/materialize-css/dist/css/materialize.min.css"] and js file path "scripts": ["node_modules/materialize-css/dist/js/materialize.min.js"]. For detail see below code.

angular.json

Option 2

You can add direct link into src/index.html file

Open src/index.html file and insert css file path into head tag and js file path insert into bottom before closing body tag. For detail see below code.

src/index.html

Include External CSS Include External JS

Please leave comments

0 Comments