I have CDN URL and I want to use it inside of the Component TypeScript file.
What would be the "right" way of dealing with CDN's in Angular 2 and greater versions?
I have CDN URL and I want to use it inside of the Component TypeScript file.
What would be the "right" way of dealing with CDN's in Angular 2 and greater versions?
If you want users to retrieve the js/css files from a CDN, you need to include these files in your index.html. Example with momentjs (Note: this is just an example, momentjs can be installed via npm in your project)
index.html
Then, to use the the script in your component, you need to manually declare the exported variables / functions to avoid TS compilation errors
component.ts
Note: some libraries have types that you can use instead, instead of using
any
. You can get these types from the @types repository