Search code examples
angularcomponentsoutputparent-childdata-sharing

Getting data from output


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.


Solution

  • 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!