2017-06-15 57 views
0

我刚开始使用Angular2,这是我的第一个项目。
https://github.com/Exlord/angular2-sample-dynamicformAngular2 ng build --prod error提供的参数与调用目标的任何签名不匹配

这个工作在开发正常,但当我尝试ng build --prod,我收到此错误:ERROR in ng:///E:/www/ng2-sample/src/app/field/field-form/field-form.component.html (2,26): Supplied parameters do not match any signature of call target.

错误是指this line

<div class="form-group" [ngClass]="{'has-error':!form.get('name').valid && form.get('name').touched}"> 

我angular2 + CLI前两天装所以我认为一切都是最新的。

我错过了什么?这是什么意思?

回答

1

您有错误这里

if (('ngSubmit' === en)) { 
    const pd_2:any = ((<any>_co.save(_co.form.value,_co.form.valid)) !== false); <= this line 
    ad = (pd_2 && ad); 
} 

距离

<form [formGroup]="form" (ngSubmit)="save(form.value, form.valid)" novalidate> 

,如果你打开现场form.component.ts文件

save(value: any): void { 
    this.submitted = true; 
    this.fieldService.save(<Field>value).then((field) => { 
    this.submitted = false; 
    this.form.reset(); 
    this.onSave.emit(); 
    }); 
} 

你可以注意到save方法只有一个参数,而您在模板中传递两个参数

+0

yeay tnx,愚蠢的构建错误:D – Exlord

0

尝试在组件提供程序中添加FormBuilder和FieldService。

@Component({ 
    selector: 'app-field-form', 
    templateUrl: './field-form.component.html', 
    styleUrls: ['./field-form.component.css'], 
    providers : [FormBuilder, FieldService] 
}) 
+0

没有变化,相同的错误。 – Exlord

相关问题