2

I'm very new to AngularJS and so far I'm loving it.

I read that wrapping external libraries into directories is the kosher thing to do, and I understand why that makes sense.

In my efforts to create a 'slickgrid' directive, I found very little info on the web. This question over here provides an example of slickgrid as a directive: Slick Grid wrapped in directive (angular), some options not work (resize and drag&drop columns)

But is that the correct way of doing it? The way that person did it, every <div slickgrid> will initialize with the same settings and data.

In my app, I'll need many instances of slickgrid, and columns will differ from instance to instance, as well as the data, of course.

So how should I link a particular <div slickgrid> to the data that is supposed to display then?

thank you very much for your time

Community
  • 1
  • 1
  • before you dig into slick grid you should check out the angular ui project - they have a directive called [`ng-grid`](https://github.com/angular-ui/ng-grid). dont take my word forit but i think it's build on slick grid. – haki Mar 08 '14 at 07:10

1 Answers1

0

as SlickGrid has way too much options - there's no really big sense in writing a directive, that fully incapsulates it. You should better initiate different grids in different controllers. And maybe move column and formatter definitions to a separate service

So the code will be something like that:

angular.module('app').controller('grid1controller', function(){
    ...
    $scope.grid = new Slick.Grid("#grid1", $scope.data, grid1columns, grid1options);
    ...
})
v1vendi
  • 603
  • 4
  • 9