S
S
Serp3nt2017-04-23 00:45:11
JavaScript
Serp3nt, 2017-04-23 00:45:11

Connecting external javascript in angular 2?

Faced with the fact that it is necessary to connect external javascript to an application on angular 2. Actually, the question is, how is this implemented?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Kustikov, 2017-04-27
@art1z

The question is not clear. If it's a package in node_modules/bower_components and not ES6 - then something like:

import * as Raphael from 'raphael'; // для класса
import 'annyang'; // для глобального объекта

If TypeScript does not compile, then create a custom-typings.d.ts file, where to describe the types:
declares interface Raphael {
  constructor(options: any);
  ...
}

declare namespace annyang {
  function start(): void;
  function pause(): void;
  function abort(): void;
  function isListening(): boolean;
  function addCommands(commands: Object): void;
  function addCallback(type: string, callback: (arg: any) => void )
}

R
Roman, 2017-05-04
@uaKorona

If I understood your question correctly and we are talking about using external scripts located, for example, in a CDN, then I connected via $script.js - JS loader & dependency
manager - something better came up with)
95e480c8b5fc49a6b23c1211594e0c41.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question