我无法从$$('.data-table #airconDatabaseTable tbody tr').on('click', function (e) {
var zaf = $$(this).closest('tr').attr('id');
console.log (zaf);
})
获得价值。它说mat-datepicker
。我使用了undefined
和ngForm
,但是我不知道我哪里错了。
ngModel
client-form.ts
<form #f="ngForm" (ngSubmit)="registerClient(f.value)">
<div class="" style="width: 50%; margin:auto;">
<!-- ... Other fields -->
<!-- ... -->
<div class="form-group">
<mat-form-field id="date">
<input matInput [matDatepicker]="picker" placeholder="Choose a date" [(ngModel)]="date">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker id="datePicked" #picker></mat-datepicker>
</mat-form-field>
</div>
<div>
</div>
<button class="btn btn-success mt-2">Add new client</button>
</div>
</form>
这些是我在控制台中遇到的错误。
ClientFormComponent.html:41错误错误:如果在表单标记中使用ngModel,则必须设置name属性或表单 控件必须在ngModelOptions中定义为“独立”。
示例1:
export class ClientFormComponent { date: Date; // ... // ... registerClient(crediantials) { let client: Client = { firstName: crediantials.firstName, lastName: crediantials.lastName, phone: crediantials.phone, doctorsName: this.selectedD.username, procedure: this.selectedP, registrationDate: this.date }; console.log(client), 'client'; console.log(crediantials) console.log(this.date, ' date); this.clientService.addClient(client); } }
示例2:
<input [(ngModel)]="person.firstName" name="first">
错误上下文DebugContext_ {view:{…},nodeIndex:69,nodeDef:{…},elDef:{…},elView:{…}}
错误错误:ViewDestroyedError:尝试使用被破坏的视图:detectChanges
这是发生错误的行。
<input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">
答案 0 :(得分:0)
如果使用ngForm,则具有ngModal的输入字段必须具有带有值的属性名称。
"server": "nodemon index.js",
"client": "cd client && npm start",
"dev": "concurrently --kill-others \"npm run server\" \"npm run client\"",