【问题标题】:angular cdk drag and drop not working in lazy-loading角度 cdk 拖放在延迟加载中不起作用
【发布时间】:2019-09-08 17:24:56
【问题描述】:

当它在 Angular 7 上出现时,我切换到延迟加载功能,在此之前,cdk 拖放可以工作,现在它坏了。

我在代码中使用了一些共享模块来集中模块,例如,每当我需要模块 A,B,C 时,我只导入模块 D,它本身会导入这些模块。

我尝试导入位于 @angular/cdk/drag-drop 的 DragDropModule 在这些共享模块之一中,它不起作用。

我还仔细检查了这些模块是否被导入到任何地方。

请注意,我确保共享模块也已导出。

共享模块

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import {DragDropModule} from '@angular/cdk/drag-drop';


@NgModule({
  declarations: [],
  imports: [DragDropModule, CommonModule],
  exports : [DragDropModule]
})
export class DragDropSharedModule {}

在其他共享模块中

import {DragDropSharedModule} from './core-shared/drag-drop.module'

@NgModule({
  declarations: [
    NavbarComponent,
    AppComponent,
    // TimeAgoPipe,
    RmSetTextComponent,
    // ToggleComponent,
    KeysPipe,
    TimeAgoPipe
    // LoadingComponent
    ////////////// AclControlComponent,
    ///////////// AclGroupListComponent,
    ////////////////////// AclPermissionComponent,
    ///////////// SelectedItemsPipe

  ],
  imports: [
    // BrowserModule,
    ReactiveFormsModule,
    FormsModule,
    Ng2FileInputModule.forRoot(),
    Ng2ImgFallbackModule,
    CommonModule,
    HttpClientModule,
    // DragDropModule,
    ScrollingModule,
    NotFountPageModule,
    RmTableModule,
    ToggleModule,
    DragDropSharedModule
  ]

【问题讨论】:

    标签: angular typescript lazy-loading angular-cdk angular-dragdrop


    【解决方案1】:

    这是我如何让它工作的方法

    <ng-container *ngFor="let item of [1,2,3,4,5]">
    <cargo cdkDrag (cdkDragEnded)="dragEnded($event)">hello</cargo>
    </ng-container>
    

    【讨论】:

    • 谢谢你的回答,我得到了它的工作;我意识到我没有在我的共享模块之一中导入拖放模块,我的坏
    【解决方案2】:

    已解决

    我没有在其中一个共享模块中导入拖放模块

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多