9
import { Component, Input, OnChanges } from '@angular/core';

@Component({
  selector: 'image-display',
  templateUrl: './image-display.component.html'
})
export class ImageDisplayComponent implements OnChanges {
  @Input() image: File;
  @Input() imagePath?: string;

  private fileReader: FileReader;

  constructor() { }

  ngOnChanges() {
    if (this.image && this.fileReader) {
      this.fileReader.readAsDataURL(this.image);
    }
  }
}

On compiling this with AOT getting below error:

PRINHYLTPAP0592:matata ajays$ ng build --prod --aot
/myApp/src/$$_gendir/app/image-uploader/image-display/image-display.component.ngfactory.ts (61,9): 
Supplied parameters do not match any signature of call target.
Ajay
  • 4,199
  • 4
  • 27
  • 47
  • `image-display.component.ngfactory.ts` - is this the file you are showing or is it an another file? If it's another one, please add that one as well. Also, template where you use this component. – Emin Laletovic Mar 30 '17 at 08:59
  • same issue here. Running build prod on angular 2.4.10 and cli 1.0 – moohkooh Mar 30 '17 at 13:26
  • i also had this issue after upgrading to ng cli 1.0 with ng2.4.10 – Arelancelot Mar 31 '17 at 14:18
  • @doyevaristo, I got issue with ngOnChanges() method actually. Check below, I have accepted the answer. – Ajay Apr 02 '17 at 05:46

2 Answers2

23

AOT forces you to inform every single mandatory parameter for every method call.

In your example, the method ngOnChanges() should actually be ngOnChanges(changes: SimpleChanges).

Pedro Penna
  • 1,127
  • 1
  • 15
  • 24
2

If there is any mismatch between method which is called from html, and the definition of the method in the component, we see this error.

mostly mismatch in the number of parameters passed to the method while calling.

I was passing $event in onModelChange method, which is not decalared in the method definition.

dropdownChanged(){
  console.log("dropdown changed");
}
dropdownChangedActual(evnt:any){
  console.log("dropdown changed");
}
<select [(ngModel)]="myModel" (ngModelChange)="dropdownChanged($event)">
     <option>.............</option>
</select>

Either declare $event or any parameters we pass or Pass the parameters as mentioned in method definition.

Swagath
  • 21
  • 1