In my Angular app (myApp
) I have a custom filter (myFilter
) and I am using UI Grid with multiple grids (myGrid1
, myGrid2
, etc.) to display my data in various view of my app. Since many of the columns are used on more than one grid, I have placed their column definitions within an Angular constant for use throughout my app.
I am not having any luck using myFilter
as a cellFilter for a subset of the column definitions in the constant. You can't inject a filter into a constant and injecting the constant into a config() also does not work (unknown provider error).
Here's a glimpse at what my code looks like:
angular.module('myApp', ['MyFilter'])
.constant('MyColumns', {
firstName: {
cellClass: 'myCellClass',
name: 'firstName'
},
lastName: {
cellClass: 'myCellClass',
// cellFiler: 'myFilter', // DOES NOT WORK
name: 'lastName'
}
// etc.
})
.filter('myFilter',
function() {
// leaving out what filter does for brevity
return;
}
)
.controller('MyController',
function (MyColumns) {
var myData; // leaving out data for brevity
var myGrid1 = {
columnDefs: [
MyColumns.lastName,
MyColumns.firstName
// etc.
],
data: myData
// etc.
};
}
)
/*
.config(function (MyColumns) {
MyColumns.lastName.cellFilter = 'myFilter'; // DOES NOT WORK
})*/
;
Is there a way I can use myFilter
on the column definitions in the constant? Thanks for your help!
versions: Angular 1.5.8, UI Grid 3.2.6