Uncaught TypeError: angular.lowercase is not a function

Sudarshan Kalebere picture Sudarshan Kalebere · May 21, 2018 · Viewed 22.9k times · Source

Uncaught TypeError: angular.lowercase is not a function

this error in my angularjs application, and entire application is not running. This is its showing in textAngular-sanitize.js:413.

Not able to debug, i tried using same version as of angular.js, but no success. Please provide me solution for this. I dont have anything to share apart from this error message in console.

textAngular-sanitize.js:413 Uncaught TypeError: angular.lowercase is not a function
        at parseEndTag (textAngular-sanitize.js:413)
        at htmlParser (textAngular-sanitize.js:378)
        at textAngular-sanitize.js:147
        at textAngularSetup.js:443
        at Object.invoke (angular.js:5093)
        at angular.js:4892
        at forEach (angular.js:374)
        at createInjector (angular.js:4892)
        at doBootstrap (angular.js:1923)
        at bootstrap (angular.js:1944)

Answer

Ovidiu Dolha picture Ovidiu Dolha · May 21, 2018

As you can see here, angular deprecated their lowercase util method.

The library you use has not updated yet and is therefore only compatible with an angular version before 1.6.7. But since you get this error, the angular version you use is probably higher.

You can either

(A) Downgrade angular to 1.6.7, in your bower.json:

"dependencies": {
   "angular": "1.6.7",
   ...
}
"resolutions": {
   "angular": "1.6.7"
}

(B) Create a simple workaround by adding these methods back as such:

angular.lowercase = text => text.toLowerCase();

Make sure this is done after angular is loaded but before your app starts.