ng2-dnd与Angular 4

时间:2017-06-23 18:15:56

标签: angular drag-and-drop drag

我试图实施拖拽和放大器在Angular项目中删除(https://github.com/akserg/ng2-dnd)。

我的配置(ng -v):

@angular/cli: 1.1.3
node: 6.10.1
os: win32 x64
@angular/animations: 4.2.4
@angular/common: 4.2.4
@angular/compiler: 4.2.4
@angular/core: 4.2.4
@angular/forms: 4.2.4
@angular/http: 4.2.4
@angular/platform-browser: 4.2.4
@angular/platform-browser-dynamic: 4.2.4
@angular/router: 4.2.4
@angular/cli: 1.1.3
@angular/compiler-cli: 4.2.4
@angular/language-service: 4.2.4

我的步骤:

  1. 创建新项目:ng new myProject --style=sass
  2. 安装ng2-dnd:npm install ng2-dnd --save
  3. NgModule 中导入 DndModule
  4. import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { AppComponent } from './app.component';
    import { DndModule } from 'ng2-dnd';
    
    @NgModule({
        declarations: [
            AppComponent
        ],
        imports: [
            BrowserModule,
            DndModule.forRoot()
        ],
        providers: [],
        bootstrap: [AppComponent]
    })
    export class AppModule { }
    
    1. node_modules
    2. 导入 style.css

      完成这些步骤之后,我就像在github上一样添加一个模板,但没有结果。我只看到纯文本,即使没有风格。

      我做错了什么?

1 个答案:

答案 0 :(得分:2)

你应该在angular-cli.json

中导入样式
 "styles": [
        "../node_modules/ng2-dnd/style.css",
      ],