How do I include a JavaScript script file in Angular and call a function from that script

0 votes
I have a JavaScript file called abc.js that has a 'public' function called xyz(). I want to call that function in my Angular project. How do I do that?
Sep 8, 2020 in Angular by kartik
• 37,510 points
3,698 views

1 answer to this question.

0 votes

Hello @kartik,

Refer the scripts inside the angular-cli.json (angular.json when using angular 6+) file.

"scripts": [
    "../path" 
 ];

then add in typings.d.ts (create this file in src if it does not already exist)

declare var variableName:any;

Import it in your file as

import * as variable from 'variableName';

Hope it helps!!
ThanK you!!

answered Sep 8, 2020 by Niroj
• 82,720 points

Related Questions In Angular

0 votes
0 answers

How to call a node file from Angular function?

I have a button in my webpage ...READ MORE

Nov 9, 2020 in Angular by Viswa
• 140 points

closed Nov 9, 2020 by Gitika 90 views
0 votes
1 answer

How can I strip HTML tags from a string in ASP.NET?

Hello @Kartik, If it is just stripping all HTML tags ...READ MORE

answered Jul 23, 2020 in Angular by Niroj
• 82,720 points
255 views
0 votes
1 answer

How to know tools and bundlers after create a new workspace or a project in angular?

Hello @sajal, When you create projects and workspaces ...READ MORE

answered Aug 6, 2020 in Angular by Niroj
• 82,720 points
131 views
0 votes
1 answer

How do I retrieve the Width and Height from this event object?

Hello @kartik, Use: <div (window:resize)="onResize($event)" onResize(event) { event.target.innerWidth; } or using ...READ MORE

answered Sep 8, 2020 in Angular by Niroj
• 82,720 points
454 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,720 points
7,253 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,720 points
823 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,720 points
642 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,720 points
7,666 views
0 votes
1 answer

How do you import a javascript package from a cdn/script tag in React?

Hello, Go to the index.html file and import ...READ MORE

answered Jun 4, 2020 in Angular by Niroj
• 82,720 points
9,455 views
0 votes
1 answer

How to call a node function from Angular ?

Hello, For your query you can refer this:https://www.codegrepper.c ...READ MORE

answered Nov 9, 2020 in Angular by Niroj
• 82,720 points
281 views