ng2-dragula [dragula] (angular2 drag and drop) - *ngFor with [dragulaModel] attribute not working

浪子不回头ぞ 提交于 2019-12-05 06:19:49

Welp, figured out the issue. The inner html is blank because the actual DOM element dragula moves is the inner html (element's content), instead of moving the element marked with attribute [dragula].

This fixed it:

    <div class='wrapper' [dragula]='"first-bag"' [dragulaModel]='fixtures'>
      <div class='container' *ngFor='let fixture of fixtures'>
        <div>{{fixture.id}}</div>
      </div>
    </div>

Their own documentation is a little unclear with this, as they have:

<ul>
  <li *ngFor="let item of items" [dragula]='"bag-one"' [dragulaModel]='items'></li>
</ul>

Moral of story: move your [dragula] and [dragulaModel] UP one element from where you put your *ngFor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!