Create filters¶
Overview¶
A filter should be placed in alight.filters (you can change path with alight.getFilter), or in scope.$ns for private filters.
alight.filters.mylimit = function(exp, cd) {
var ce = cd.compile(exp); // compile the input expression
return function(value) { // return handler
var limit = Number(ce() || 5);
return value.slice(0, limit)
}
}
Input arguments¶
- expression - an input expression
- cd - change detector
The filter should return a handler/function, one instance of filter.