打字稿中的错误〜属性在void类型中不存在]] << [

问题描述 投票:2回答:1
好吧,我有一些用角度引导程序制作的代码,它是一个数据选择器,它在事件方寄存器(您单击新建并创建新事件)中,并且我希望用户选择一个日期并保存它,这里是日期选择器的代码:

<p>Selecione a data</p> <ngb-datepicker #dp [startDate]="modelAtual" [(ngModel)]="modelAtual" (navigate)="date = $event.next"></ngb-datepicker> <pre>Month: {{ date.month }}.{{ date.year }}</pre> <pre>Model: {{ model | json }}</pre>

然后我有保存日期信息的代码,在打字稿中:

salvarImagem() { if (this.chave === undefined) { let dat1=new Date().getMilliseconds(); const filePath = `/eventos/${dat1}-${this.selecionado["lastModified"]}` + '.' + this.selecionado['tipoarquivo']; const fileRef = this.storage.ref(filePath); const task = this.storage.upload(filePath, this.file); let datahoje = new Date(this.modelAtual.year,this.modelAtual.month,this.modelAtual.day).getTime(); this.selecionado['dataInicial']=datahoje; var horario = this.time.hour + ':'+ this.time.minute; this.selecionado['horaInicial']=horario; // observe percentage changes this.uploadPercent = task.percentageChanges(); // get notified when the download URL is available task.snapshotChanges().pipe( finalize(() => { this.downloadURL = fileRef.getDownloadURL(); this.downloadURL.toPromise().then(du => { this.selecionado["arquivo"] = du; this.service.add(this.selecionado); this.router.navigate(['/eventos']); alert("Objeto salvo"); }); }) ).subscribe(); } else { this.service.update(this.chave, this.selecionado); this.router.navigate(['/estabelecimentos']); alert("Objeto salvo"); } }

然后,我有代码可以在用户想要编辑该寄存器时加载(您可以执行此操作),并且为了准确显示他之前选择的日期,我尝试将变量modelAtual分配给变量datahoje,由于某种原因返回标题中提到的错误

if (this.chave !== undefined) { this.service.get(this.chave).valueChanges().subscribe(obj => { this.selecionado = obj; this.logo = this.selecionado["arquivo"]; //this.modelAtual = { year: 2011, month: 7, day:23}; this.modelAtual = this.salvarImagem().datahoje; }) }

任何人都可以告诉我原因吗?

好吧,我有一些用角度引导程序制作的代码,这是一个数据选择器,它位于事件方寄存器(您单击新建并创建新事件)中,并且我希望用户...

html angular typescript date void
1个回答
0
投票
TL; DR(简短答案):
© www.soinside.com 2019 - 2024. All rights reserved.