使用 ngFor 绑定对象时,组件在 Angular2 for Dart 中不可拖动

Components are not draggable in Angular2 for Dart when bind objects using ngFor

我创建了一个组件,它是一个可拖动元素。

@Component(
    selector: 'draggable-component',
    styles: const ['.element-to-drag {background-color: yellow; border: 1px solid blue; height: 50px; width: 50px;}'],
    template: '''
      <div class="element-to-drag"
           draggable="true"
           (dragstart)="onDragStart($event)"
           (dragend)="onDragEnd($event)">
      </div>''')
class DraggableComponent {
  void onDragStart(MouseEvent e) {
    print('onDragStart');
  }

  void onDragEnd(MouseEvent e) {
    print('onDragEnd');
  }
}

这是一个例子:

@Component(
    selector: 'my-app',
    directives: const [DraggableComponent, NgFor],
    styles: const ['.container {border: 1px solid red;; height: 100px; width: 100px;}'],
    template: '''
  <div>
    <div class="container"></div>
    <h3>Single</h3>
    <draggable-component></draggable-component>
    <h3>Primitives</h3>
    <draggable-component *ngFor="#example of examplesPrimitives"></draggable-component>
    <h3>Objects</h3>
    <draggable-component *ngFor="#example of examples"></draggable-component>
  </div>
  ''')
class AppComponent {
  get examples => [
    {"name": 1},
    {"name": 2},
    {"name": 3},
    {"name": 4} ];

  get examplesPrimitives => [ 1,2,3,4,5];
}

如何使对象的绑定可拖动?

这是 Angular2 机智 Dart 错误。 Angular2 使用 TypeScript 在相同情况下工作正常。

在 Angular 存储库中创建了一个问题: https://github.com/angular/angular/issues/6975