我有一张桌子,上面有项目清单和一个按钮,可以向我显示详细信息:
HTML
<changeSet id="1" author="Me">
<dropPrimaryKey tableName="tv_campaigns"/>
<addColumn tableName="tv_campaigns">
<column name="ID" type="bigint(20)" autoIncrement="true">
<constraints nullable="false" primaryKey="true" unique="true"/>
</column>
</addColumn>
<addAutoIncrement tableName="tv_campaigns" columnName="ID" columnDataType="bigint(20)"/>
</changeSet>
TS
<ng-container matColumnDef="details">
<mat-header-cell *matHeaderCellDef mat-sort-header> Details</mat-header-cell>
<mat-cell *matCellDef="let row">
<button mat-button color="primary" (click)="getDetails($event)">Details</button>
</mat-cell>
</ng-container>
console.log(event.value)的结果是未定义的。
但是当我使用这样的下拉菜单时:
HTML
getDetails(event) {
this.filter.type= "items2"
this.filter.filterObject= event.value;
this.commonService.searchClientiClick(this.filter);
console.log(event.value);
}
TS
<p-dropdown [options]="DropDownItem" filter="true" (onChange)="onChangeItem($event)"
[(ngModel)]="selectedItem" >
</p-dropdown>
有效!正确获取ID。 为什么?我在哪里错了?