Angular 7 and CDNs | angular 7 cdn
IfyouwanttouseCDNsthenindex.htmlistheplacetodoit.However,themorecommonapproachistonpminstallthelibyouwanttouseandthenloaditfromthenode_modulesfolderusingangular.jsonSo,forexample,tousebootstrapCSSthisway:npminstall--savebootstrapTheninangular.json"styles":["node_modules/bootstrap/dist/css/bootstrap.css"]Thenrestartyourserver.Allthebootstrapstyleswillbebundledupinyourappandaccessiblefromanycomponent.Noteinangular.jsonthereare2stylesarray,youwantthefirstone.Whenyouwanttoupdatetoanewerversionof...
If you want to use CDNs then index.html is the place to do it.
However, the more common approach is to npm install the lib you want to use and then load it from the node_modules folder using angular.json
So, for example, to use bootstrap CSS this way:
npm install --save bootstrapThen in angular.json
"styles": [ "node_modules/bootstrap/dist/css/bootstrap.css" ]Then restart your server. All the bootstrap styles will be bundled up in your app and accessible from any component.
Note in angular.json there are 2 styles array, you want the first one.
When you want to update to a newer version of bootstrap, just npm install the newer version.
The benefit of using node_modules is (1) accessing a resource locally is faster than accessing a resource from the internet (2) once node_modules are installed your app no longer relies on an internet connection to grab the resource.