@jpachcomorales wrote:
hi i am a noob here but i need some help, this is only for practice for to understand how to work Ionic2 and it is my University homework too, the App consist in a main template that containt a result template, but i need to call to a function in my result template with the search key of my main template's search bar for it make a JSON request and get the data for show them in the result template that containt the main template, this is my code:
In my app.html:
<div id="sbar"> <ion-searchbar [(ngModel)]="_valor" id="searchbox" (keyup)='upkey($event)' (keydown)='downkey($event)'></ion-searchbar> </div>
In my app.js:
class MyApp {
export _valor: String;
constructor(app: IonicApp, platform: Platform, http: Http) {
this.app = app;
this.platform = platform;
this.http=http;
this.prueba = "Variable param";
this.Leyes = [];
this.url = 'http://www.########.com/resultados.json?q=';
this.initializeApp();this.pages = [ { imagen: 'build/img/home.png', title: 'Home', component: GettingStartedPage }, { imagen: 'build/img/info38.png', title: 'Ayuda', component: AyudaHTML }, { imagen: 'build/img/faq7.png', title: 'Preguntas Frecuentes', component: FaqHTML } { imagen: 'build/img/cloud158.png', title: 'Actualizaciones', component: ActualizacionesHTML }, { imagen: 'build/img/news29.png', title: 'Novedades', component: NovedadesHTML }, { imagen: 'build/img/two205.png', title: '¿Te gustaría colaborar?', component: ColaborarHTML }, { imagen: 'build/img/multiple25.png', title: 'Acerca', component: AcercaHTML}, ]; this.rootPage = GettingStartedPage;(this is te result template)
}
this is my result template:
export class GettingStartedPage implements OnInit{ constructor(app: IonicApp,http: Http) { this.http=http; this.Leyes = []; this.url = 'http://www.#######.com/resultados.json?q='; alert('Constructor GettingStartedPage'); }
//*************************************************************
ngOnInit(){ alert("OnInit"); } buscar(texto) { ... } }
i need to pass the searchbar's value to a function in my result template "GettingStartedPage" for it make the request at the server and get the request consult but i don't know first: how to pass the search key to the function in "GettingStartedPage" and second how do i insert the request's result in my result template, i already have tried with @Input and with a Service and i tried creating an object... please help me or advise me something...
Posts: 1
Participants: 1