Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase Angularfire2*用于在Ionic 2应用程序中不更新DOM_Firebase_Ionic Framework_Ionic2_Angularfire2_Ngfor - Fatal编程技术网

Firebase Angularfire2*用于在Ionic 2应用程序中不更新DOM

Firebase Angularfire2*用于在Ionic 2应用程序中不更新DOM,firebase,ionic-framework,ionic2,angularfire2,ngfor,Firebase,Ionic Framework,Ionic2,Angularfire2,Ngfor,我正在使用Ionic和Firebase后端制作一个社交媒体应用程序,我使用Angularfire2与之通信 我的应用程序中有一个页面,通过从NavParams接收uid来列出用户的所有关注者,并将其发送给提供商,提供商返回该用户关注者的FirebaseListObservable 关注者页面。ts constructor(public navCtrl: NavController, public navParams: NavParams, public util: UtilProvider,

我正在使用Ionic和Firebase后端制作一个社交媒体应用程序,我使用Angularfire2与之通信

我的应用程序中有一个页面,通过从NavParams接收uid来列出用户的所有关注者,并将其发送给提供商,提供商返回该用户关注者的FirebaseListObservable

关注者页面。ts

constructor(public navCtrl: NavController, public navParams: NavParams, public util: UtilProvider,  public userProvider: UserProvider, public socialProvider: SocialProvider, private zone: NgZone) {
    this.name = this.navParams.get('name');
    this.otherUid = this.navParams.get('uid');
    this.currentUid = this.userProvider.currentUid();
}

ionViewDidLoad() {
    this.zone.run(() => {
        this.users = this.userProvider.getUserFollowers(this.otherUid);
    });
}
//Get List of followers of uid
getUserFollowers(uid) {
    let users = this.af.database.list(`/users/${uid}/followers`, {
        query: {
            limitToFirst: 10
        }
    });
    return users;
}
followers page.html

<ion-header>
    <ion-navbar color='danger'>
        <ion-title>{{name}} Followers</ion-title>
    </ion-navbar>

</ion-header>


<ion-content padding>
    <ion-list>
        <ion-item style="background-color: #fff" *ngIf="!(users | async)">
            <ion-avatar item-left>
                <img src="assets/img/defaultAvatar.png">
                <h2>Loading...</h2>
            </ion-avatar>
        </ion-item>

        <user-item *ngFor="let user of users | async" [user]="user">
        </user-item>
    </ion-list>
</ion-content>
<ion-item style="background-color: #fff" text-wrap>
    <ion-avatar item-left (click)="userProfile()">
        <img [class]="user.visibility > 1 ? 'profile-pic verified' : 'profile-pic'" [src]="user?.avatar ? user.avatar : 'assets/img/defaultAvatar.png'">
    </ion-avatar>
    <h2 (click)="userProfile(user)">{{user?.name}}</h2>
    <button ion-button item-right *ngIf="!(following)" (click)="followUser()">{{user?.followerCount}} Followers</button>
    <button ion-button outline item-right icon-left *ngIf="following" (click)="followUser()">
        <ion-icon name="checkmark"></ion-icon>Followed
    </button>
</ion-item>
user item.html

<ion-header>
    <ion-navbar color='danger'>
        <ion-title>{{name}} Followers</ion-title>
    </ion-navbar>

</ion-header>


<ion-content padding>
    <ion-list>
        <ion-item style="background-color: #fff" *ngIf="!(users | async)">
            <ion-avatar item-left>
                <img src="assets/img/defaultAvatar.png">
                <h2>Loading...</h2>
            </ion-avatar>
        </ion-item>

        <user-item *ngFor="let user of users | async" [user]="user">
        </user-item>
    </ion-list>
</ion-content>
<ion-item style="background-color: #fff" text-wrap>
    <ion-avatar item-left (click)="userProfile()">
        <img [class]="user.visibility > 1 ? 'profile-pic verified' : 'profile-pic'" [src]="user?.avatar ? user.avatar : 'assets/img/defaultAvatar.png'">
    </ion-avatar>
    <h2 (click)="userProfile(user)">{{user?.name}}</h2>
    <button ion-button item-right *ngIf="!(following)" (click)="followUser()">{{user?.followerCount}} Followers</button>
    <button ion-button outline item-right icon-left *ngIf="following" (click)="followUser()">
        <ion-icon name="checkmark"></ion-icon>Followed
    </button>
</ion-item>

{{user?.name}
{{user?.followerCount}}追随者
跟着
在没有limitToFirst查询的情况下,它将正确的追随者数量显示为用户项,但个人资料头像、姓名和追随者状态均为空。当我点击化身时,它会推送正确的用户配置文件页面,这样数据就在那里,但DOM不会被更新

我在我的应用程序的“发现”选项卡中有完全相同的代码(没有NgZone),它在那里工作得非常好

我在没有NgZone的情况下也尝试过,但是没有用,所以我完全不知道如何显示这些用户的信息


提前谢谢

ngOnChanges
不会在
用户项中触发component@Aravind有没有办法确保它被触发?用修改过的代码更新帖子,尝试将代码放入
IonViewWillEnter()
。我感觉视图已加载,但在加载视图后对firebase的调用仍在进行中,因此显示为空白。单击时,数据已加载,然后导航良好。最佳做法是在服务器提取过程中让加载程序显示这两个建议,但它们似乎都不起作用:/
ngOnChanges
不会在
用户项中触发component@Aravind有没有办法确保它被触发?用修改过的代码更新帖子试着把代码放进去
IonViewWillEnter()
。我感觉视图已加载,但在加载视图后对firebase的调用仍在进行中,因此显示为空白。单击时,数据已加载,然后导航良好。最佳做法是在服务器提取过程中让加载程序显示这两种建议,但它们似乎都不起作用:/