Angular 5.2 AOT build error Expected 0 arguments, but got 1 when using $event

Md Ghouse picture Md Ghouse · Feb 22, 2018 · Viewed 8.2k times · Source

I am capturing output event in method without parameter and it's working fine. but when i try to build AOT --prod getting folloing error.

Expected 0 arguments, but got 1

Html code: SaveSortOrder($event)
backend code: SaveSortOrder() {}

Answer

Daniel Gimenez picture Daniel Gimenez · Feb 22, 2018

AOT is very strict. In this case you are passing the value of $event when you call SaveSortOrder, but the method doesn't accept one. Either change the html not to pass $event or add an argument to SaveSortOrder.

Do one of the following:

Html code <button click="SaveSortOrder()" />

backend SaveSortOrder($event: any) { /* ... */ }