Hi guys,
In m first load of the app, I want to load an ion-list from other tab that currently tab, for example, when load Tab1 I needed load the ion-list of Tab2. But when I opened this tab the content of the list dont’show.
Any idea?
Hi guys,
In m first load of the app, I want to load an ion-list from other tab that currently tab, for example, when load Tab1 I needed load the ion-list of Tab2. But when I opened this tab the content of the list dont’show.
Any idea?
Sounds like you want to centralize the list into a service provider that can be injected in multiple places.
What I want is to update a list (ion-item) in my component list.ts / list.html from tabs.ts component.
From tabs.ts I call the service that brings me the data from the list, but I do not know how to load it into my list.ts, where I have the ngFor with the list
Given only what I’ve heard so far, I would have the service expose an Observable<Thingy[]>
(probably some sort of Subject
). Pages that care when this list of thingies is modified would subscribe to this and update their own copy of a Thingy[]
property accordingly. The mechanism for calling next()
on the Subject
depends on the rest of your design.
I have this
tabs.ts
constructor(public listPage: ListPage){
this.listPage.getCars();
}
list.ts
export class ListPage {
cars: Cars[] = [];
constructor(){}
getCars(){
this.cars = arrCars;
}
}
list.html
<ion-item-sliding *ngFor="let car of cars">
<ion-item >
<h2>{{car.name}}</h2>
</ion-item>
</ion-item-sliding>
The problem is that when call this.getCars() from tabs.ts and after open the tab of cars, I didn’t see nothing
No. Don’t ever inject one page into another. It makes no sense.
I agree to @rapropos. Do not use it like that.
But you insist of this, you can add it to localStorage as window.localStorage[‘Cars’];
Or you can add list as a parameter I believe like;
<ion-tab [root]="tab1Root" tabIcon="search" [rootParams]="Cars"></ion-tab>