To add an external js file into Angular 4, follow these steps:

  • Refer the scripts inside the angular-cli.json file like this:
    "scripts": [ "../path" ];
  • Add this into typings.d.ts :
    declare var variableName:any;
  • Import the above onto your js file as:
    import * as variable from 'variableName';
BY Best Interview Question ON 20 Jan 2020