【问题标题】:Reference.child failed: First argument was an invalid path="[object Object]"Reference.child 失败:第一个参数是无效的 path="[object Object]"
【发布时间】:2018-04-13 17:59:03
【问题描述】:

新的角度。

我正在尝试删除我的系列数据库中的一个赛季,当我删除一个系列时它可以,但是当我尝试删除一个赛季时它可以

错误:

ERROR Error: Reference.child failed: First argument was an invalid path = "[object Object]". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"
    at Object.exports.validatePathString (validation.js:282)
    at Reference.child (Reference.js:74)
    at Object.stringCase (remove.js:8)
    at checkOperationCases (utils.js:19)
    at Object.remove (remove.js:7)
    at SeriesDataService.deleteSeason (series-data.service.ts:73)
    at SeasonDetailComponent.delete (season-detail.component.ts:44)
    at Object.eval [as handleEvent] (SeasonDetailComponent.html:28)
    at handleEvent (core.js:13547)
    at callWithDebugContext (core.js:15056)

我的 SeasonDetailComponent.html 看起来像这样:

<div *ngIf="season">
<h2>Season {{season.Number}} details</h2>
<div>
     <label>Number:
      <input [(ngModel)]="season.Number" placeholder="Number"/>
    </label><br/>
    <label>Image: 
    <img src="" alt="">
        <input  [(ngModel)]="season.Image" placeholder="Image source">
    </label><br/>
    <label>First_Episode_Air_Date:
      <input [(ngModel)]="season.First_Episode_Air_Date" placeholder="First_Episode_Air_Date"/>
    </label><br/>
    <label>Last_Episode_Air_Date:
      <input [(ngModel)]="season.Last_Episode_Air_Date" placeholder="First_Episode_Air_Date"/>
    </label><br/>
</div>

</div>
<button (click)="goBack()">Go back</button>
<button [routerLink]="['./episodes']">Episodes</button>
<button (click)="delete()">X</button>

季节细节组件:

 delete(): void{
    this._data.deleteSeason(this.serieId, this.season.Number);
    this.goBack();
  }

我的 series-data.service.ts 是这样的:

deleteSeason (idSerie: number , Number: number):  void {
    const indexSerie = this.db.list(this.authService.userDetails.uid+"/"+idSerie+"/").valueChanges();;
    const indexSeason = this.db.list(this.authService.userDetails.uid+"/"+idSerie+"/Seasons"+Number).valueChanges();
    //this.db[serieId].Seasons.splice(indexSeason, 1);
    console.log("Removing: "+idSerie+ " season " +Number);
    this.db.list(this.authService.userDetails.uid).remove(indexSeason.toString());
  } 

谢谢!

【问题讨论】:

  • 你的console.log fire 呢?你在什么时候收到错误,是在你的点击事件之后吗?
  • 当我尝试在此处执行 .remove 时出现错误 this.db.list(this.authService.userDetails.uid).remove(indexSeason.toString());

标签: angular firebase


【解决方案1】:

问题已解决!

将 series-data.service 的 deleteSeason 更改为:

deleteSeason (id:number,serieId):void {
    console.log("Removing: "+serieId+" season " +id);
    this.db.list(this.authService.userDetails.uid+"/"+serieId+"/Seasons").remove(id.toString());
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-21
    • 2016-11-30
    • 2017-09-12
    • 2018-01-15
    • 2017-12-01
    • 1970-01-01
    相关资源
    最近更新 更多