我正在Angular 2中创建一个表单.我的目标是从API获取数据并将其传递到表单中以进行编辑.但是,我遇到了这个错误:
EXCEPTION:未捕获(在承诺中):错误:./EditPatientComponent类中的错误EditPatientComponent - 内联模板:1:10引起:formGroup需要一个FormGroup实例.请通过一个.
这是带错误的当前代码.
HTML
<section class="CreatePatient">
<form [formGroup]="patientForm" (ngSubmit)="onSubmit()">
<div class="row">
<div class="form-group col-12 col-lg-3">
<label for="firstName">First Name</label>
<input formControlName="firstName" type="text" class="form-control" id="firstName" >
</div>
<div class="row">
<div class="col-12 col-lg-2">
<button type="submit" name="submit" class="btn btn-block btn-primary">Save</button>
</div>
</div>
</form>
</section>
Run Code Online (Sandbox Code Playgroud)
TS
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { FormBuilder, FormGroup, FormControl } from '@angular/forms';
import { PatientService } from './patient.service';
import { Patient } from './patient';
@Component({
templateUrl: …Run Code Online (Sandbox Code Playgroud) 我对在角度矩中使用amDifference滤镜有疑问.
目前我的设置如下:
{{order.shipDate | amDifference: null: 'days'}}
Run Code Online (Sandbox Code Playgroud)
这是计算出货日期和当前日期之间的差异,但如果是的话,它会向后退出.例如,如果我的shipDate在12/05/2015,它当前显示'-81',但我希望它显示'81'.所以我想这样的事情:
{{currentDate | amDifference: order.shipDate: 'days'}}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过了:
{{null | amDifference: order.shipDate: 'days'}}
Run Code Online (Sandbox Code Playgroud)
哪个没用.
所以我想我想知道:
非常感谢!