我对angular2和离子很新。所以我试图实现一个接受值的表单,并将提交给服务。我收到错误:
Error in ./RecordvisitPage class RecordvisitPage - caused by: formGroup expects a FormGroup instance. Please pass one in.
这是我的html页面:
<ion-content>
<form [formGroup]="recordVisitForm">
<ion-item>
<ion-label>Action Date</ion-label>
<ion-input formControlName="actionDate" name="actionDate"></ion-input>
</ion-item>
<ion-item>
<ion-label>Contacted</ion-label>
<ion-input formControlName="contacted" name="contacted"></ion-input>
</ion-item>
</form>
<ion-footer>
<button ion-button navPop>Back</button>
<button ion-button (click)="saveVisit()">Save</button>
</ion-footer>
所以附加到这个html页面的组件是:
public recordVisitForm: FormGroup;
constructor(public navCtrl: NavController, private loanService : LoanService, public formBuilder: FormBuilder, public params: NavParams) {
this.loan = params.get('loan');
this.recordVisitForm = formBuilder.group({
actionDate: ['', Validators.required],
contacted: ['', Validators.required],
});
}
答案 0 :(得分:1)
lut = [ [1], // n=0
[1,1], // n=1
[1,2,1], // n=2
[1,3,3,1], // n=3
[1,4,6,4,1], // n=4
[1,5,10,10,5,1], // n=5
[1,6,15,20,15,6,1]] // n=6
binomial(n,k):
while(n >= lut.length):
s = lut.length
nextRow = []
nextRow[0] = 1
for(i=1, prev=s-1; i<prev; i++):
nextRow[i] = lut[prev][i-1] + lut[prev][i]
nextRow[s] = 1
lut.push(nextRow)
return lut[n][k]
binomial(4,2)
this