Firebase:Reference.set失败:指定的第一个参数路径超出了可以写入的最大深度(32)或对象的属性中包含循环

时间:2018-07-11 17:30:39

标签: android angular firebase ionic-framework firebase-realtime-database

我尝试使用Ionic在Firebase的名为 jugadoresApuntados 的mapa.ts中插入/更新数组。当我尝试时,这是我的错误:

控制台

Apuntarse a partido con user [object Object]

mapa.ts:99 Jugadores apuntados que vamos a grabar: Juan Martinez Fdz

Error: Reference.set failed: First argument path specified exceeds the maximum depth that can be written (32) or object contains a cycle in property 'partido-list.-LH9HVmUWSF-pa5Aee1Q.lastOpen._infoWindowManager._mapsWrapper._zone.onUnstable.observers.0._subscriptions.0._parent._subscriptions.0._parent._subscriptions.0._parent._subscriptions.0._parent._subscriptions.0._parent._subscriptions.0._parent._subscriptions.0._parent._subscriptions.0.closed'
    at ValidationPath.checkValid_ (Path.js:304)
    at ValidationPath.push (Path.js:284)
    at validation.js:148
    at Object.exports.forEach (obj.js:37)
    at Object.exports.validateFirebaseData (validation.js:132)
    at validation.js:149
    at Object.exports.forEach (obj.js:37)
    at Object.exports.validateFirebaseData (validation.js:132)
    at validation.js:149
    at Object.exports.forEach (obj.js:37)

MAPA.HTML

<agm-map [latitude]="latitude" [longitude]="longitude">
 <agm-marker  *ngFor="let partido of pachangas | async; let i = index" [latitude]="partido.lat" 
[longitude]="partido.log" (markerClick)="markerClick(infoWindow, partido)"   >
<agm-info-window>
<div>
        <button ion-button full (click)="apuntarseAPartido(partido)">Apuntarse</button>
    </div>

  </agm-info-window>
</agm-marker>
</agm-map>

MAPA.TS

我在构造函数中声明了服务:

constructor(public navCtrl: NavController, public navParams: NavParams, public platform: Platform, public partidosS: PartidosListService,
    public partidosJugadoresService : PartidosJugadoresService,
    public afAuth: AngularFireAuth,
    private fb: Facebook){}



apuntarseAPartido(partido : Partido){

     this.currentUser = this.afAuth.auth.currentUser;
      if( this.currentUser != null){
       console.log("Apuntarse a partido con user " + this.currentUser);
        if(partido.jugadoresApuntados!=null)
           partido.jugadoresApuntados.push(this.currentUser.displayName);
        else{
           partido.jugadoresApuntados=[];
           partido.jugadoresApuntados.push(this.currentUser.displayName);
           }

        }else{
        this.fb.getLoginStatus().then(res =>{
          console.log("Apuntarse a partido via face con user "+ res.authResponse.name );
          partido.jugadoresApuntados.push(res.authResponse.name);
        });
      }
      console.log("Jugadores apuntados que vamos a grabar: "+ partido.jugadoresApuntados)
      this.partidosS.updatePartido(partido);

*这是jugadoresApuntados的Partido模型:

export interface Partido {

    key?: string; 
    id_partido: string;
    titulo: string;
    fecha: string;
    ciudad: string;
    direccion: string;
    lat: number;
    log: number;
    nombreCancha: string;
    cubierta: boolean;
    Opciones: {
        apikey: string;
        city: string;
        unitFormat: string;
        lang: string;
    },
    resulEquipo1: string;
    resulEquipo2: string;
    txtEquipo1: string;
    txtEquipo2: string;
    ganador: string;
    jugadoresApuntados: Array<string>;
}

partido.ts

updatePartido(partido: Partido) {

            return this.partidoListRef.set(partido.key, partido);
        }

y尝试了*return this.partidoListRef.update(partido.key, partido);*,但结果相同。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

我知道问题出在哪里:  不能包含带有div的按钮。解决方案以离子卡为例:

  <ion-card>
        <div>
            <button ion-button full (click)="apuntarseAPartido(partido)">Apuntarse</button>
        </div>
    </ion-card>

它有效!