Skip to content

Commit 5ae52a7

Browse files
committed
feat: remove the DragAndDropModule.forRoot method
BREAKING CHANGE: The `DragAndDropModule.forRoot` method was removed. To migrate just import the `DragAndDropModule` module directly
1 parent cf1bc61 commit 5ae52a7

6 files changed

+17
-22
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ https://mattlewis92.github.io/angular-draggable-droppable/demo/
1414

1515
## Table of contents
1616

17-
* [About](#about)
18-
* [Installation](#installation)
19-
* [Documentation](#documentation)
20-
* [Development](#development)
21-
* [License](#licence)
17+
- [About](#about)
18+
- [Installation](#installation)
19+
- [Documentation](#documentation)
20+
- [Development](#development)
21+
- [License](#licence)
2222

2323
## About
2424

@@ -40,7 +40,7 @@ import { DragAndDropModule } from 'angular-draggable-droppable';
4040

4141
@NgModule({
4242
declarations: [DemoApp],
43-
imports: [DragAndDropModule.forRoot()],
43+
imports: [DragAndDropModule],
4444
bootstrap: [DemoApp]
4545
})
4646
class DemoModule {}
@@ -77,8 +77,8 @@ https://mattlewis92.github.io/angular-draggable-droppable/docs/
7777

7878
### Prepare your environment
7979

80-
* Install [Node.js](http://nodejs.org/) and NPM (should come with)
81-
* Install local dev dependencies: `npm install` while current directory is this repo
80+
- Install [Node.js](http://nodejs.org/) and NPM (should come with)
81+
- Install local dev dependencies: `npm install` while current directory is this repo
8282

8383
### Development server
8484

demo/demo.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DemoComponent } from './demo.component';
55

66
@NgModule({
77
declarations: [DemoComponent],
8-
imports: [BrowserModule, DragAndDropModule.forRoot()],
8+
imports: [BrowserModule, DragAndDropModule],
99
bootstrap: [DemoComponent]
1010
})
1111
export class DemoModule {}

src/drag-and-drop.module.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
import { NgModule, ModuleWithProviders } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { DraggableDirective } from './draggable.directive';
33
import { DroppableDirective } from './droppable.directive';
4-
import { DraggableHelper } from './draggable-helper.provider';
54

65
@NgModule({
76
declarations: [DraggableDirective, DroppableDirective],
87
exports: [DraggableDirective, DroppableDirective]
98
})
10-
export class DragAndDropModule {
11-
static forRoot(): ModuleWithProviders {
12-
return {
13-
ngModule: DragAndDropModule,
14-
providers: [DraggableHelper]
15-
};
16-
}
17-
}
9+
export class DragAndDropModule {}

src/draggable-helper.provider.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { Subject } from 'rxjs';
2+
import { Injectable } from '@angular/core';
23

4+
@Injectable({
5+
providedIn: 'root'
6+
})
37
export class DraggableHelper {
48
currentDrag: Subject<any> = new Subject();
59
}

test/draggable.directive.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('draggable directive', () => {
4040

4141
beforeEach(() => {
4242
TestBed.configureTestingModule({
43-
imports: [DragAndDropModule.forRoot()],
43+
imports: [DragAndDropModule],
4444
declarations: [TestComponent]
4545
});
4646
});

test/droppable.directive.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as sinon from 'sinon';
55
import { triggerDomEvent } from './util';
66
import { DragAndDropModule } from '../src/index';
77
import { DraggableDirective } from '../src/draggable.directive';
8-
import { DroppableDirective } from '../src/droppable.directive';
98

109
describe('droppable directive', () => {
1110
@Component({
@@ -55,7 +54,7 @@ describe('droppable directive', () => {
5554

5655
beforeEach(() => {
5756
TestBed.configureTestingModule({
58-
imports: [DragAndDropModule.forRoot()],
57+
imports: [DragAndDropModule],
5958
declarations: [TestComponent]
6059
});
6160
});

0 commit comments

Comments
 (0)