forked from angular-ui/ui-grid
-
Notifications
You must be signed in to change notification settings - Fork 2
Plugins
Crash8308 edited this page Oct 31, 2012
·
9 revisions
Creating Plugins
Example of a plugin:
myPlugin = function(){
var self = this;
//@new child scope of the Grid scope for you to create watches or whatever you want.
//@gridInstance = instance of the grid object where the plugin is initialized.
self.init = function(childScope, gridInstance){
//initialize plugin vars and functions here.
};
};
To register a plugin you need to pass it to the ng-grid directive as part of the options object:
function bodyController($scope) {
var self = this;
self.myPlugin = function(){
var pSelf = this;
pSelf.init = function(gridChildScope, gridInstance){
//do some init work here
}
}
self.myData = [{name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: 29},
{name: "Enos", age: 34}];
$scope.gridOptions = { data : self.myData,
plugins: [ self.myPlugin ]};
}