Ionic v2 http service provider not working

I created project in ionic with blank template after that i added 2 pages and 1 provider. Provider is for calling my api from pages but provider gives some simple error but i dont know what is happening here.

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class NoteService 
{
	data: any;
	constructor(public http: Http) 
	{
		console.log('Hello NoteService Provider');
	}

	load() 
	{
	}
}

I dont know why this is happening i haven’t right code in provider that is comes from ionic generator command.

Please help me out…!

You probably forgot to import the HttpModule into your app.module ?

1 Like

Thanks for your reply. i missed to include that. i did like

import { HttpModule } from ‘@angular/http’;

and pass in import like

imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpModule
],

Means if i have to use any module first i have to include in app.module.ts file after that in service file or other pages. but can you just tell me why we have to write it.

HttpModule i cannot right any word instead of that?

Because otherwise the build system doesn’t know to include the code needed to make http requests. Apps that don’t make http requests don’t want to include that code needlessly.

Ok. Thanks i thought ionic is did that automatically because i use command line for generator provider but that is need to do manually. Thanks for your quick answer.