After just starting with ng2, I decided to create a project using angular-cli. However, I soon realized that I needed some third-party modules such as Google Maps API, Lodash, and JQuery. Although I have a basic understanding of Typescript, I was unsure how to incorporate these modules into an Angular2 app without relying on existing ng2 modules or components built on top of them.
In the past, when working with JavaScript, I would simply include the JS file and reference the API documentation to know which methods to use. With Angular2, I wasn't sure what steps to take to achieve the same result.
My research led me to believe that I should first install the necessary Typescript files. For example, for Google Maps, I used
npm install --save @types/google-maps
. Now, my question is whether I need to import this module into my Angular app by including it in app.module.ts, in the imports array, or if it is globally available.
One source suggested installing it with npm and then adding a reference to the library in the scripts array of my angular-cli.json like this:
"scripts": ['./node_modules/googlemaps/googemaps.min.js'],
Which method is best for installing the Google Maps API? Considering that the rest of my Angular app will be written in Typescript, I assumed Typescript might be the way to go.
Now, in my app.component.ts, I want to create a simple map using the Typescript version of Google Maps that I installed. How can I accomplish this? The Google Maps API recommends creating a new instance of the map like this:
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
scrollwheel: false,
zoom: 8
});
But how do I do this using the Typescript version of Google Maps that I just installed?
Would the Typescript version of Google Maps have all the same methods as the original API? Are there documentation sites for typescripts of popular JS libraries that I can refer to?