If you want the information regarding weather of a particular city, then ```ng4-weather``` is for you.
npm install ng4-weatherng4-weather` is for you.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
$3
Install via NPM:
`sh
npm install --save ng4-weather
`
or
`sh
npm i --save ng4-weather
`
$3
Step 1 :
Import HttpModule in app.module.js
`sh
import { HttpModule } from '@angular/http';
...
@NgModule({
declarations: [
...
],
imports: [
...
HttpModule
...
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
`
Step 2 :
In any of your fileName.ts :
`sh
import { Search } from 'ng4-weather/core';
`
Step 3 :
`sh
Search("cityName", http, (data) => {
// do something here
console.log(data);
})
`
First parameter is the, name of city, you want to search.
Second parameter is the, Http object.
Third parameter is the callback function, i.e. data here contains all the attributes that you can use in your code.
Use data.attributeName or data.attributeName.subAttributeName.
For example : data.city , data.main.temp etc.
$3
You can change Unit of temperature by using respective mathematical formulas.
For example : data.main.temp gives value in Kelvin. So, for getting unit of temperature in Celcius, subtract 273.15 from Kelvin` value.