第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Angular - 無(wú)法讀取未定義的屬性“id”

Angular - 無(wú)法讀取未定義的屬性“id”

每當(dāng)我嘗試創(chuàng)建新票時(shí),都會(huì)收到以下錯(cuò)誤消息:無(wú)法讀取未定義的屬性“id”這是我的 thread.service.ts,其中有用于創(chuàng)建票證的 AddTicket 方法: addTicket(id: string,heading: string,user: string,date: Date,description: string,likeCount: number,timeLeft: number){  const newTicket = new Threads  (    id,    heading,    user,    new Date(date),    description,    likeCount,    timeLeft  );  let generatedId: string;  return this.http  .post<{ name: string }>(    'https://ionic-angular-a0570.firebaseio.com/all-tickets.json',    {      ...newTicket,      id: Math.random().toString()    }  )  .pipe(    switchMap(resData => {      generatedId = resData.name;      return this.tickets;    }),    take(1),    tap(tickets => {      newTicket.id = generatedId;      this._tickets.next(tickets.concat(newTicket));    })  );}我正在調(diào)用 new-thread.page.ts 中的方法:  onCreateTicket(){this.threadService.addTicket(this.threads.id, this.heading, this.registerService.user, this.threadService.getDate(), this.description, +this.threadService.getLikes(), +12).subscribe();如果有幫助,這是我的threads.model.ts:export class Threads {constructor(    public id: string,    public heading: string,    public user: string,    public date: Date,    public description: string,    public likeCount: number,    public timeLeft: number){}}新線(xiàn)程.page.ts:import { Component, OnInit } from '@angular/core';import { ThreadsService } from '../main/departmentforum/threads/threads.service';import { NavController } from '@ionic/angular';import { RegisterService } from '../register/register.service';import { Threads } from '../main/departmentforum/threads/threads.model';@Component({  selector: 'app-new-thread',  templateUrl: './new-thread.page.html',  styleUrls: ['./new-thread.page.scss'],})export class NewThreadPage implements OnInit {  heading: string;  description: string;  businessforum: string;  departmentforum: string;  threads: Threads;  constructor(private navController: NavController, private threadService: ThreadsService, public registerService: RegisterService) {}  ngOnInit() {  }
查看完整描述

1 回答

?
桃花長(zhǎng)相依

TA貢獻(xiàn)1860條經(jīng)驗(yàn) 獲得超8個(gè)贊

threadsnew-thread.page.ts 中的變量已聲明但從未初始化。它應(yīng)該用一些數(shù)據(jù)初始化。例如。


threads: Threads = new Threads(

  '0', 

  '', 

  '', 

  new Date((new Date()).getTime() + 24*60*60*1000), 

  '', 

  null, 

  null

);


查看完整回答
反對(duì) 回復(fù) 2022-05-14
  • 1 回答
  • 0 關(guān)注
  • 182 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)