Skip to content

Commit

Permalink
Merge branch 'wip/dragula-options-input-binding' of git://github.com/…
Browse files Browse the repository at this point in the history
…mgiuliani/ng2-dragula into mgiuliani-wip/dragula-options-input-binding
  • Loading branch information
valorkin committed Jan 17, 2017
2 parents 6b209f1 + f3efa21 commit 69286d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ class ConfigExample {
}
```

You can also set your options by binding an options object to the `dragulaOptions` attribute.

```js
options: any = {
removeOnSpill: true
}
```

```html
<div [dragula]='"bag-one"' [dragulaOptions]="options"></div>
<div [dragula]='"bag-two"' [dragulaOptions]="options"></div>
```

## Events

Whenever a `drake` instance is created with the `dragula` directive, there are several events you can subscribe to via `DragulaService`. Each event emits an `Array` where the first item is the name of the bag. The remaining items depend on the event. The sample below illustrates how you can use destructuring to assign the values from the event. Refer to: https://github.com/bevacqua/dragula#drakeon-events
Expand Down
2 changes: 1 addition & 1 deletion src/components/dragula.class.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import * as dragulaExpt from 'dragula';
export const dragula: (value?: any) => any = (dragulaExpt as any).default || dragulaExpt;
export const dragula: (containers?: any, options?: any) => any = (dragulaExpt as any).default || dragulaExpt;
5 changes: 2 additions & 3 deletions src/components/dragula.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { dragula } from './dragula.class';
export class DragulaDirective implements OnInit, OnChanges {
@Input() public dragula: string;
@Input() public dragulaModel: any;
@Input() public dragulaOptions: any;
private container: any;
private drake: any;

Expand Down Expand Up @@ -34,9 +35,7 @@ export class DragulaDirective implements OnInit, OnChanges {
checkModel();
this.drake.containers.push(this.container);
} else {
this.drake = dragula({
containers: [this.container]
});
this.drake = dragula([this.container], Object.assign({}, this.dragulaOptions));
checkModel();
this.dragulaService.add(this.dragula, this.drake);
}
Expand Down

0 comments on commit 69286d3

Please sign in to comment.