I am writing a custom filter which involves needing some data map to be initialised so that the data map is not created everytime the filter is invoked.
I do this:
myModule.filter("myfilter", function($filter) {
    return function(letter) {
         // ...
         var blah = myOtherFunction(letter) 
    }
}
var myOtherFunction = function() {
    // initialise some data
    var myData = {
        "a":"letterA"
        "b":"letterB"
    }
    return function(letter) {
       return myData[letter];
    }
}();
This means the file where I define my filter has a utility function which uses a closure to close over data which is initialised once and once only.
I am wondering is there a more angular way to achieve this?
Thanks
 
     
     
    