hello
my ionic view ngfor not updating after push a new element to array
impossible, show us some code
export class NotiPage {
@Input() search: string = "";
homePage: Component;
category: any;
members2:any[]=[];
assets: FirebaseListObservable<any>;
constructor(public navCtrl: NavController, public navParams: NavParams, private modalCtrl : ModalController, private zone: NgZone,public angFire: AngularFireDatabase, public loadingCtrl:LoadingController, public alert: AlertController) {
}
ionViewDidEnter(){
this.assets= this.angFire.list('/date/noti');
this.assets.subscribe(snapshots=>{
if(snapshots.length > 0){
for(let i =0 ; i < snapshots.length ; i++){
this.members2.push(snapshots[i]);
}
}});
}
html code
<ion-navbar>
<ion-buttons left>
<button color="danger" ion-button icon menuToggle>
<ion-icon name="menu"></ion-icon></button>
</ion-buttons>
<ion-title>noti</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item *ngFor=" let item of members2" text-wrap end>
<ion-thumbnail item-left>
<img src="./assets/images/18.jpg" />
</ion-thumbnail>
<h2>{{item.title}}</h2>
<p>
<span>{{item.mass}}</span>
<br>
<span>{{item.time}}</span>
</p>
</ion-item>
</ion-list>
</ion-content>
maybe you are not pushing anything
try
console.log(this.members2)
after this:
for(let i =0 ; i < snapshots.length ; i++){
this.members2.push(snapshots[i]);
}
i tried it and get data
so maybe this:
console.log(this.members2)
for(let i =0 ; i < snapshots.length ; i++){
console.log(snapshots[i];
this.members2.push(snapshots[i]);
}
console.log(this.members2)