5

I am new to Angular and recently start to learn it by reading a book 'ng-book The Complete Book on Angular 4'. In the 'how angular works' chapter I wrote a small inventory app followed by the instructions on the book but having issue after startup, shown as below: error log on browser console

All my components seem alright and the errors are just not seem relevant to my code. I even compared to the example code downloaded and they look very identical.

I know it's probably not that much of a big deal and I should move on and go back to this when I gain more knowledge. But really it's bothering me...

Not sure what's the best way of showing all my source code here so I created a shareable google drive link and a .zip with everything in that project can be retrieved by the link. ANY HELP WILL BE HIGHLY APPRECIATED!!!

https://drive.google.com/file/d/0B76fFkACV6wRdmtJU0Jfc0J4U1U/view?usp=sharing

3
  • By the way, the project was created by angular cli. And a smaller .zip with only src can be accessed by drive.google.com/file/d/0B76fFkACV6wRbkY2M1p5NHRnUW8/… Commented Jun 14, 2017 at 12:03
  • pro tip: to showcase full code you could use github, specially if your projects are open source :) Commented Jun 14, 2017 at 12:09
  • In which component is the error triggered? Commented Jun 14, 2017 at 12:13

1 Answer 1

9

In ProductsListComponent, you need to change :

@Output() onProductSelected: EventEmitter<Product>;

to :

@Output() onProductSelected = new EventEmitter<Product>();

Also, remove the line in ngOnInit in the same component.

The event emitter needs to be initialized when the class is created. See this example : http://learnangular2.com/outputs/

Sign up to request clarification or add additional context in comments.

1 Comment

Spot on! Thank you so much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.