Can one override core provider like $templateCache while maintaining reference to the original provider ?
I'd like to override $templateCache to be case insensitive.
I.E. something like
var normalGet = $templateCache.get;
var normalPut = $templateCache.put;
$templateCache.get = function(key) { normalGet(key.toLowerCase()); };
$templateCache.put = function(key,value) { normalPut(key.toLowerCase(), value); };
But less hacky, more DI-style ?
I'd say use decorator to modify the actual Provider code which will be done at configuration phase before coming into action.
We used $templateCacheProvider because Provider appended prefix indicate that its provider(it can be Directive when you are modifying directive DDO of directive). You have to place this code inside config phase of your application.
Code
app.config(['$provide', Decorate]);
function Decorate($provide) {
$provide.decorator('$templateCacheProvider',
['$delegate', function($delegate) {
var templateCache = $delegate[0];
var normalGet = templateCache.get;
var normalPut = templateCache.put;
templateCache.get = function(key) { return normalGet(key.toLowerCase()); };
templateCache.put = function(key,value) { normalPut(key.toLowerCase(), value); };
return $delegate;
}]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With