A
A
Alexey Polyakov2017-06-24 11:32:22
Angular
Alexey Polyakov, 2017-06-24 11:32:22

Is it possible to use Angular 2 with third party code?

I want to use threejs and angular2 on the site. Given that angular takes the dom for itself and builds an event model, how can third-party js code be integrated into this model so that there are no conflicts or any execution delays? Is it correct to write threejs code in angular heatplates or only through attaching modules?
ps The question is caused by the bootstrap example, which has its own separate ngb module, while the js from bootstrap also works ... why then a separate ngb?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
ozknemoy, 2017-06-24
@ozknemoy

The best solution is an adapter to Angular. for threejs, for example this https://github.com/amcdnl/ng2-three-demo
, bootstrap has moments when its usual implementation stops working under angular. like tabs and modals

A
Aleksei Podgaev, 2017-06-25
@alexiusp

Javascript bootstrap code is not tied to zones (scope in the first version) of angular. This leads to desynchronization of their work (angular does not know about the bootstrap callbacks and the callback in the bootstrap does not have access to the data of the angular controller) and in some cases to the impossibility of working together, especially if the bootstrap components (tabs, for example) are dynamically generated.
In order for Angular to "know" about the bootstrap components, they are wrapped in "adapters". There are similar adapters for most other popular libraries. The author above has already given an example of such an adapter for the library you are interested in.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question