簡體   English   中英

從另一個 function 到 function 的角度傳遞值?

[英]Angular- Pass value to function from another function?

在我的 Angular Typescript 文件中,我有 2 個函數datalists 我正在嘗試將變量windows從 function 數據傳遞到 function 列表。

我越來越Cannot find name 'back'. Did you mean the instance member 'this.lists'?ts(2663) 嘗試調用 function 列表時Cannot find name 'back'. Did you mean the instance member 'this.lists'?ts(2663)錯誤

更新

如果我使用this.list ,當我使用console.log(windows)時,它會給出undefined

data(less: Mark, quick: HTMLTableDataCellElement) {
  const { a,b,c } = less;
  const windows = quick.innerText;
  lists(windows);     ------>>>>> Cannot find name 'lists'. Did you mean the instance member 'this.lists'

  this.value.newLevel({a, b, c windows}).subscribe(data => {
    this.processView(data);
  })
}

lists(windows){
 console.log(windows) ---> If I use this.lists the value is undefined
}

列表位於同一個 class 中,因此您嘗試訪問 object 內的 function。 您必須調用 this.list 而不是調用 list

//Here is your solution             
data(less: Mark, quick: HTMLTableDataCellElement) {
const { a,b,c } = less;
const windows = quick.innerText;
this.lists(windows);

this.value.newLevel({a, b, c windows}).subscribe(data => {
  this.processView(data);
})
}
lists(windows){}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM