【发布时间】:2019-12-09 11:21:07
【问题描述】:
我有一个要求,我正在使用 Angular Material 制作嵌套的拖放组件。 所以我必须限制界限。
<ul cdkDropList [cdkDropListConnectedTo]="listIds">
<li *ngFor="let item of array" cdkDrag> ///item = {name: 'Adam', children: [...etc]}
....some work here
<ng-container *ngIf="item.children.length > 0">
/// call the <ul> again recursively
</ng-container>
</li>
</ul>
一切都很好,但我想限制边界,所以我在ul 中添加了动态类,
<ul cdkDropList [cdkDropListConnectedTo]="listIds" class="{{item.componentGuid}}">
/// class becomes some guid, eg: class="asd-123-qwe"
想用同一个类来li拖动,
<li *ngFor="let item of array" cdkDrag cdkDragBoundary="">
//this takes string like, cdkDragBoundary="here class name given in ul",
如果ul 有类test-boundary,
<ul cdkDropList [cdkDropListConnectedTo]="listIds" class="test-boundary" >,
那么li就是,
<li cdkDragBoundary=".test-boundary" cdkDrag>
但如果ul 有一个动态类,
eg:class="{{item.componentGuid}}, which will resolve to
class="asd-123-qwe", then how do I add that to cdkDragBoundary??
我尝试过的事情。
<li [cdkDragBoundary]="item.componentGuid" and few others.
【问题讨论】:
标签: angular drag-and-drop angular-material angular-cdk