Uncaught TypeError: angular.lowercase is not a function

后端 未结 8 1499
感动是毒
感动是毒 2021-02-02 08:58

Uncaught TypeError: angular.lowercase is not a function

this error in my angularjs application, and entire application is not running. This

相关标签:
8条回答
  • 2021-02-02 09:45

    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
    
    0 讨论(0)
  • 2021-02-02 09:48

    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

    0 讨论(0)
  • 2021-02-02 09:50

    Another appropriate solution would be replace textAngular with testAngularJs as suggested here.

    npm install textangularjs

    0 讨论(0)
  • 2021-02-02 09:52

    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;  
    });
    
    0 讨论(0)
  • 2021-02-02 09:52

    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.

    0 讨论(0)
  • 2021-02-02 09:53

    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;
    
    0 讨论(0)
提交回复
热议问题