我正在尝试创建一个水平的可拖动列表,其中的项目应该是可编辑的。为此,我使用了不带material和[contentEditable]='true'属性的cdk包。但这些项目不可编辑。我怎么才能让它工作?
<div cdkDropList [cdkDropListOrientation]="'horizontal'" class="namingConventionDragDrop"
(cdkDropListDropped)="drop($event)">
<ng-container *ngFor="let item of resultConvention; let i = index;">
<div cdkDrag class="pop naming-placeholder" *ngIf="item.type === 'placeholder'">
{{item.value}}
<fa-icon (click)="remove(i)" icon="times-circle"></fa-icon>
</div>
<div cdkDrag class="pop" *ngIf="item.type === 'text'
[contentEditable]="true" (click)="onItemClick($event)">
{{item.value}}
<fa-icon (click)="remove(i)" icon="times-circle"></fa-icon>
</div>
<div class="pop deactivated" *ngIf="item.type === 'extension'">
{{item.value}}
</div>
</ng-container>
</div>
<div class="naming-convention preview">
<span>Preview:</span>
{{preview}}
</div>因为我认为它与focus有关,所以我添加了一个focus()调用:
onItemClick(event) {
event.target.focus();
}前台预览。用户应该能够编辑类型为“text”的项目:

发布于 2019-02-27 20:48:15
角度CDK似乎吸收了左击事件。一种选择是使用右键单击进行编辑。
https://stackoverflow.com/questions/54249632
复制相似问题