I am learning Angular and need to create some custom filters.
Do I create one filters.js
file and put all my filters in there similar to all my reusable factory.js
?
Eg: I have a utilsFactory.js
and I put reusable functions in here.
Does this then get injected into the controllers? Or is this loaded in the $rootscope
somewhere?
I have seen many examples on how to create them but not how to store and manage them and how to access them properly
filter.js
angular.module('achApp', [])
.filter('myUpperCase', function(){
return function(value){
return String(value).toUpperCase();
}
});
Controller
(function(){
var DevbController = function($scope, utilsFactory, $filter){
$scope.greeting = 'hello';
};
DevbController.$inject = ['$scope', 'utilsFactory', '$filter'];
angular.module('achApp')
.controller('DevbController', DevbController)
}());