ng4-weather v0.0.9
Ng4-Weather
If you want the information regarding weather of a particular city, then ng4-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.
Installation
Install via NPM:
npm install --save ng4-weatheror
npm i --save ng4-weatherUsage & Quick Guide
Step 1 :
Import HttpModule in app.module.js
import { HttpModule } from '@angular/http';
...
@NgModule({
declarations: [
...
],
imports: [
...
HttpModule
...
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }Step 2 :
In any of your fileName.ts :
import { Search } from 'ng4-weather/core';Step 3 :
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.
Note
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.
License
MIT