2017-06-15 25 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

相關問題