【问题标题】:Can't bind to 'cdkDragFreeDragPosition' since it isn't a known property of 'div'无法绑定到“cdkDragFreeDragPosition”,因为它不是“div”的已知属性
【发布时间】:2020-12-26 02:04:02
【问题描述】:

我在下面发布了我的代码。我正在使用角度 DragDropModule 并且由于某种原因 [cdkDragFreeDragPosition] 无法正常工作。它给了我下面显示的错误。我将 DragDropModule 添加到我的 ngModule 中,如下所示。当我删除[cdkDragFreeDragPosition] 标签时,拖放工作正常,但一旦添加它就会给我下面显示的错误。 [cdkDragStartDelay]="1000" 也给出了同样的错误。我不知道为什么会出现这个问题。试图在网上找到解决方案,但不能。任何帮助将不胜感激。

<div class="example-boundary">
<div class="example-box"
     cdkDragBoundary=".example-boundary"
     cdkDrag
     *ngFor="let table of tables"
     id="{{table._id}}"
     (cdkDragEnded)="dragEnd($event)"
     [cdkDragDisabled]="false"
     [cdkDragFreeDragPosition]="getTablePosition(table)"
     (cdkDragMoved)="dragMoved($event, table)">{{table.username}}
</div>
import { ServerOrderComponent } from './server-order/server-order.component';
import {DragDropModule} from '@angular/cdk/drag-drop';

@NgModule({
  imports: [
    MDBBootstrapModule.forRoot(),
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [HttpClient]
      }
    }),
    BrowserModule,
    ReactiveFormsModule,
    HttpClientModule,
    routing,
    FormsModule,
    NotifierModule.withConfig(customNotifierOptions),
    HttpModule,
    MatIconModule,
    BrowserAnimationsModule,
    MatSidenavModule,
    MatCheckboxModule,
    MatFormFieldModule,
    MatTableModule,
    MatSortModule,
    MatDividerModule,
    MatButtonToggleModule,
    MatProgressSpinnerModule,
    NgMultiSelectDropDownModule.forRoot(),
    DragDropModule
  ],
  entryComponents: [],
  declarations: [
    AppComponent,
    ServerOrderComponent
  ],
  providers: [
  ],
  bootstrap: [AppComponent]
})

export class AppModule {
}

【问题讨论】:

    标签: drag-and-drop frontend angular7 angular-cdk-drag-drop


    【解决方案1】:

    所以在环顾四周后,我决定升级到 angular material 8,因为我使用的是不支持的 angular 7。升级后就可以正常使用了。

    【讨论】:

      猜你喜欢
      • 2017-08-26
      • 2020-10-24
      • 1970-01-01
      • 2019-11-04
      • 2017-09-09
      • 2021-05-08
      • 2020-09-10
      • 2017-03-29
      相关资源
      最近更新 更多