Pass Data from a Page to Provider


Is it possible to pass data from Page to Provider.?
If yes, how we can do it.

My HTML is:

		<ion-label floating>Search anything...</ion-label>
		<ion-input type="text" [(ngModel)]="search"></ion-input>

and my Provider is

 constructor(public http: Http) {
		this.http.get('**SearchFromHtmlPage**').map(res => res.json()).subscribe(
				this.posts = data.records;

I want to pass value of search of html page to provider in the link


1 Like

It doesn’t make much sense to be doing that in the constructor. Assuming you’re injecting the provider in the page, the value won’t be available yet. I would define a getStuff method in the provider that takes an argument, and then call that from the page when you have the parameter defined.

Thanks Robert.
It helped.

IS there a possibility of sending me the sample code of how would you do that?