0

i do it and get result:

  a(table: Table) {
    console.log(table)
  }

enter image description here

But when i try:

a(table: Table) {
  console.log(table.initialized)
}

i get just undefined. if i try:

  a(date: string, table: Table) {
    if (table.initialized) {
      ...
    }
  }

It also treats table.initialized as undefined, meaning it's not in the console bug. Can you explain how it is possible? Func call here:

<p-table #table ... (onLazyLoad)="a(table)" dataKey="id">
Get Off My Lawn
  • 34,175
  • 38
  • 176
  • 338
evrei666
  • 83
  • 4
  • 2
    If you’re calling the `a(date: string, table: Table)` function with `a(table)`, then the function thinks `table` is the `date` parameter, and that the `table` parameter is undefined. – padeso Jan 21 '23 at 14:54
  • @padeso Error in the question, arguments are passed correctly of course – evrei666 Jan 21 '23 at 15:02
  • 2
    Does this answer your question? [Is Chrome’s JavaScript console lazy about evaluating objects?](https://stackoverflow.com/questions/4057440/is-chrome-s-javascript-console-lazy-about-evaluating-objects) Use your debugger instead of `console.log` debugging. – jabaa Jan 21 '23 at 15:07
  • Is the `table` argument a promise? It looks to me like you're using the PrimeNG `onLazyLoad` callback incorrectly. What are you trying to accomplish? – Meqwz Jan 21 '23 at 15:25
  • it is most likely that the object isn't there till after you printed to the console. The console will show the current state of the object when it is viewed, and since objects can mutate after printing to the console you are seeing a delayed change. https://stackoverflow.com/questions/11284663/console-log-shows-the-changed-value-of-a-variable-before-the-value-actually-ch – Get Off My Lawn Jan 21 '23 at 21:53
  • If you put a debugger point in the browser to see the value of table, it doesn't show the property initialised. But you will get the property of table.loading as true. – Haseena P A Jan 22 '23 at 21:53
  • You are calling it `(onLazyLoad)=“a(table)”`. How you should call it is `(onLazyLoad)=“a(data, table)”` – Parzh from Ukraine Jan 24 '23 at 10:16

1 Answers1

0
try:

 a( table: Table) {
    if (table.initialized) {
      //your code is here....
    }
  }

as your passing table, you one more parameter date, obviously table will empty and you will be getting undefined error.