我有一个从数据库调用的商品清单。我在每个框旁边创建了一个按钮,用于保存有关商品的信息,单击该按钮会显示一个表格,该表格可让您更改所需的商品。
问题在于,如果我将表单控件留空,那么它将更改实际报价,并且我不希望这样做,因此,如果表单字段为空,则不会计数。
这是 HTML 组件:
origin/todo
TS 文件:
<div id="editOffer2" style="display: none">
<div class="container">
<div class="row">
<div class="col-md-6 offset-md-3">
<form [formGroup]="editofferForm" (ngSubmit)="editOffer()">
<div class="form-group" style="margin-top: 30px;">
<label style="font-weight: 600; margin-right: 50px; font-size: 1rem">Offer Name</label>
<input type="text" formControlName="offername" class="form-control">
<!-- <div *ngIf="submitted && d.offername.errors" class="invalid-feedback">
<div *ngIf="d.offername.errors.required">Offer Name is required</div>
</div> -->
</div>
<div class="form-group" style="margin-top: 30px;">
<label style="font-weight: 600; margin-right: 50px; font-size: 1rem">Description</label>
<textarea formControlName="description" class="form-control" cols="40" rows="9"></textarea>
<!-- <div *ngIf="submitted && d.description.errors" class="invalid-feedback">
<div *ngIf="d.description.errors.required">Description is required</div>
</div> -->
</div>
<div class="form-group" style="margin-top: 30px;">
<label style="font-weight: 600; margin-right: 50px; font-size: 1rem">Contact</label>
<input type="text" formControlName="contact" class="form-control" />
<!-- <div *ngIf="submitted && d.contact.errors" class="invalid-feedback">
<div *ngIf="d.contact.errors.required">Contact is required</div>
</div> -->
</div>
<div class="form-group" style="margin-top: 30px;">
<label style="font-weight: 600; margin-right: 50px; font-size: 1rem">Location</label>
<input type="text" formControlName="location" class="form-control"/>
<!-- <div *ngIf="submitted && d.location.errors" class="invalid-feedback">
<div *ngIf="d.location.errors.required">Location is required</div>
</div> -->
</div>
<div class="form-group" style="margin-top: 30px;">
<label style="font-weight: 600; margin-right: 50px; font-size: 1rem">Salary</label>
<input type="text" formControlName="prix" class="form-control" />
<!-- <div *ngIf="submitted && d.prix.errors" class="invalid-feedback">
<div *ngIf="d.prix.errors.required">Price is required</div>
</div> -->
</div>
<div class="form-group" style="margin-top: 30px;">
<label style="font-weight: 600; margin-right: 50px; font-size: 1rem">Category:</label>
<select formControlName="services" style="width: 150px">
<option *ngFor="let s of allServices" [ngValue]="s">{{s.serviceName}}</option>
</select>
</div>
<!-- <div class="form-group">
<mat-select placeholder="Pick Category" formControlName="services" [ngClass]="{ 'is-invalid': submitted && d.services.errors }">
<mat-option *ngFor="let s of services" [value]="s.serviceName">
{{s.viewValue}}
</mat-option>
</mat-select>
<div *ngIf="submitted && d.services.errors" class="invalid-feedback">
<div *ngIf="d.services.errors.required">You must choose a category</div>
</div>
</div> -->
<div class="form-group">
<button class="btn btn-primary" type="submit">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>