Uncaught TypeError: angular.lowercase is not a function
this error in my angularjs application, and entire application is not running. This
if you are using angularjs with typescript and a linter (in my case, tslint + standard), a correct workaround would be :
if (!angular.lowercase) (angular as any).lowercase = (text: string) => angular.isString(text) ? text.toLowerCase() : text
I found a similar issue when updated to angular 1.7.5 , my solution was to update angular-sanitize and the problem was fixed. angular-sanitize
Another appropriate solution would be replace textAngular
with testAngularJs
as suggested here.
npm install textangularjs
Angular 1.7.* still has lowercase function but it's renamed to $$lowercase. This is a possible workaround. Buyer beware based on Angular documentation.
angular.module('MyApp').config(function() {
angular.lowercase = angular.$$lowercase;
});
I am using AngularJS v1.7.5 . In my controller, I have used below code to convert a string into lowercase:
function myCtrl($scope, $filter)
{
var sampleText = "THIS IS TEST";
var test = $filter('lowercase')(sampleText);
}
Inject $filter in the controller and use the same to convert to lowercase.
Ovidiu Dolha's answer got me almost there. If you look at the pre-deprecation implementation of the lowercase
function, it is a bit more. This shim implementation did the trick for me:
/**
* @brief Shim for textAngular in order to make it compatible with the latest
* version of angularjs
*/
function lowercase(string) {
return (typeof string === 'string') ? string.toLowerCase() : string;
}
// Angular deprecated the lowercase function as of v1.6.7. TextAngular hasn't
// updated to reflect this
angular.lowercase = lowercase;