Reputation: 3393
What I'm using
What I'm trying to do
What happens
Supplied parameters do not match any signature of call target.
What i've tried
Component HTML
Below is the HTML snippet that's causing the issue. I'm taking values from input fields and pushing them through to a function. When running 'ng build -watch', i have no issues whatsoever, everything works. Only on the 'prod' command do I receive the error in the terminal
<div class="vs__details__actions">
<button class="vs__button"
[disabled]="!selectedFiles"
(click)="submitForm(newTitle.value, newReference.value, newDate.value, newAuditorName.value, newCompanyName.value); newTitle.value='';
newReference.value=''; newDate.value=''; newAuditorName.value=''; newCompanyName.value=''">
Add
</button>
</div>
Component Typescript file
import { Component, OnInit } from '@angular/core';
import { ProjectsAddService } from './projects-add.service';
import { Upload } from './upload';
import * as _ from "lodash";
@Component({
selector: 'upload-form',
templateUrl: './projects-add.component.html',
styleUrls: ['./projects-add.component.css']
})
export class ProjectsAddComponent {
selectedFiles: FileList;
currentUpload: Upload;
constructor(private upSvc: ProjectsAddService) { }
detectFiles(event) {
this.selectedFiles = event.target.files;
}
uploadSingle() {
let file = this.selectedFiles.item(0)
this.currentUpload = new Upload(file);
}
submitForm(title: string, reference: string, date: string, auditorName: string, newCompanyName: string, upload: Upload) {
let file = this.selectedFiles.item(0)
this.currentUpload = new Upload(file);
this.upSvc.submitForm(title, reference, date, auditorName, newCompanyName, this.currentUpload);
}
}
Any help would be greatly appreciated :)
Upvotes: 1
Views: 659
Reputation: 8165
With --prod
(production mode) angular-cli will use AoT (Ahead of Time compilation).
AoT is a bit more sensible about types, signatures and stuff.
your submitForm
function expects a (not optional) upload: Upload
argument as last parameter, which you don't pass on click.
Two options here:
First (and suggested) way: Make it optional like submitForm(title: string, reference: string, date: string, auditorName: string, newCompanyName: string, upload?: Upload)
Alternative: pass null
at the last argument in your template.
Hope it helps.
Update: After your edit of your question and your comment, i should probably just add the third option here: Just remove the param, if it's not used in your function.
Upvotes: 3
Reputation:
Your submit forms requires 6 parameters and you're calling that function with 5 values in your template. You're missing the value for "upload".
Upvotes: 1