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,520 points
14,074 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!!

 If you need to know more about Java, join our Java certification course online.

ThanK you!!

answered Sep 8, 2020 by Niroj
• 82,880 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 844 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,880 points
1,757 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,880 points
847 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,880 points
4,413 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,880 points
22,937 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,880 points
2,959 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,880 points
2,894 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,880 points
44,358 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,880 points
25,023 views
0 votes
1 answer

How to call a node function from Angular ?

Hello, For your query you can refer this:https://www.codegrepper.com/code-examples/javascript/how+to+call+a+function+when+a+button+is+clicked+in+javascript Hope ...READ MORE

answered Nov 9, 2020 in Angular by Niroj
• 82,880 points
1,974 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP