7

Initially i was getting following error while publishing angular .net core SPA App:

Can't resolve rxjs/operators in release\directives

Which i have resolved by updating the rxjs version to 5.6.

Now while publishing the app i am getting following errors:

 WARNING in EnvironmentPlugin - NODE_ENV environment variable is undefined.

You can pass an object with default values to suppress this warning.
See https://webpack.js.org/plugins/environment-plugin for example.

ERROR in ng:///D:/ClientApp/app/components/search/search.component.html (15,91): Expected 0 arguments, but got 1.

ERROR in ng:///D:/ClientApp/app/components/search/search.component.html (134,32): Expected 0 arguments, but got 1.

ERROR in ng:///D:/ClientApp/app/components/search/search.component.html (278,25): Expected 1 arguments, but got 0.

ERROR in ng:///D:/ClientApp/app/components/search/search.component.html (15,91): Expected 0 arguments, but got 1.

ERROR in ng:///D:/ClientApp/app/components/search/search.component.html (134,32): Expected 0 arguments, but got 1.

ERROR in ng:///D:/ClientApp/app/components/search/search.component.html (278,25): Expected 1 arguments, but got 0.

Search.Component.html file :

<div class="search">
<div class='panel panel-primary'>
    <div class='panel-heading resultbar'>
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <span class=' navbar-toggle collapsed glyphicon glyphicon-menu-hamburger' (window:resize)="onZoomIn($event)" (click)="toggleHeader()" style="cursor: pointer;" placement="top"></span>
        **</div>**

Not able to understand the issue

S2K
  • 1,185
  • 3
  • 27
  • 55

3 Answers3

6

I found why this error was caused, this is my former @HostListener within my class:

@HostListener("window:resize", ["$event.target"])
onResize() {
    this.getElWidth();
}

As Prasant Jaya said the error is thrown because I forgot to put a param in onResize(). Now this is my new code slightly modified and working fine:

@HostListener("window:resize", ["$event.target"])
onResize(event) {
    this.getElWidth();
}

It may be better for you to use @HostListener in your class than listening to window resizing directly in the template if you want to resolve this error.

Bugs
  • 4,491
  • 9
  • 32
  • 41
Olivier Cadoz
  • 116
  • 1
  • 6
  • 1
    Brilliant you saved my night on this, I just want to add that this error is trowed every time you invoke a function in the component from the template and you are missing an argument (or declaring the wrong number etc) so it is not specific for this case with the @HostListener Ad maiora! – Glabler Jul 21 '19 at 23:57
  • 1
    Works perfectly, thanks! Just a small improvement, instead of declaring an unused `event` parameter, you can also just write `@HostListener("window:resize")`, which is a cleaner solution IMO. – JSON Derulo Jun 22 '21 at 06:41
5

This error happens when you call a function from view in component without or with less parameters. The component function call should have same number of parameters as you declared in the function.

If you are still getting the same error then try adding any to the parameter, it accepts any type of value.

onZoomIn(event : any){
  console.log(event);
}
Prasanth Jaya
  • 4,407
  • 2
  • 23
  • 33
1

I got this error and effectively, I had a function in my component expecting to receive one parameter, and I called without any in my template :facepalm:

Mateo Tibaquira
  • 2,059
  • 22
  • 23