Getting data from output

39 Views Asked by At

I have npm called ngx-snake. I would like to collect data about points. In documentation has been written

#### Outputs

Name  | Description
--- | ---
foodEaten | Called whenever our sweet snake gained some weight ;)
gameOver | :( collision! snake didn't make it (remember about reset button)

so in my component.html I write

    <div class="container-user">
      <ngx-snake (foodEaten)="showResult($event)"></ngx-snake>
    </div>

and in component.html

  showResult(points: any): void {
    console.log(points++);
  }

But in fact there is no information about points. It shows another game-grid. I tried also change to

but it also not work.

2

There are 2 best solutions below

0
chrystian On BEST ANSWER

I am late to the party but still the first one :) Have you managed to figure it out?

The library itself is not giving you any information about points... you just get info about event that might be useful in implementing your own scores system.

The lib was developed to assist in angular learning so... there is bunch of things that you have to do with it yourself

best!

0
JCC_PP On

yeah, im also late but anyways..

whats happening here is that you are actullay passing an event to your function and not the score itself, so get the event and check it to see what iti usefull to you and keep that info!