It seems like it should be easy, but I can't find the documentation on it. I am wondering how to make an Angular component (say, a filter) reusable in different applications. I created a simple filter that formats a phone number, and I would like to use it in any application. Currently, it is declared as follows:
var myModule = angular.module('myModule', ['ngSanitize']);
myModule.filter('formatFilter', function() {
return function(input) {
return input.replace(/(\d{3})(\d{3})(\d{4})/, "($1) $2-$3");
}
});
The question is how to make this filter multiple. Right now it is just tied to "myModule", but how can I extract it from this file to use it again elsewhere?
source
share