programing

Uncatched TypeError: angular.lowercase가 함수가 아닙니다.

newnotes 2023. 4. 5. 22:13
반응형

Uncatched TypeError: angular.lowercase가 함수가 아닙니다.

Uncatched TypeError: angular.lowercase가 함수가 아닙니다.

angularjs 어플리케이션에서 이 오류가 발생하여 어플리케이션 전체가 실행되지 않습니다.이것은 에 게재된 것입니다.textAngular-sanitize.js:413.

디버깅할 수 없기 때문에 angular.js와 동일한 버전을 사용하려고 했지만 성공하지 못했습니다.이에 대한 해결책을 제시해 주십시오.콘솔에 이 에러 메시지 외에 공유할 것이 없습니다.

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)

보시다시피 앵글 디커버레이션은lowercaseutil 메서드

사용하는 라이브러리는 아직 업데이트되지 않았으므로 1.6.7 이전 버전의 각 버전과만 호환됩니다.하지만 이 오류가 발생했기 때문에 사용하는 각도 버전이 더 높을 수 있습니다.

둘 중 하나를 선택할 수 있습니다.

(A) bower.json의 각도를 1.6.7로 다운그레이드합니다.

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

(B) 다음과 같은 방법을 추가하여 간단한 회피책을 만듭니다.

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

각도가 로드된 후 앱이 시작되기 전에 이 작업을 수행해야 합니다.

Angular 1.7.*에는 소문자 함수가 있지만 이름이 $$lowercase로 변경되었습니다.이것은 생각할 수 있는 회피책입니다.구매자는 Angular 문서에 따라 주의해야 합니다.

angular.module('MyApp').config(function() {
  angular.lowercase = angular.$$lowercase;  
});

저처럼 어려운 사람들에게 도움이 될 수 있도록 제 의견을 공유하고 싶은데, 가장 큰 문제는 각도입니다.JS는 공식적으로 라이브러리에서 소문자 및 대문자 함수를 삭제하여 textAngular-sanitize.js를 사용하는 사용자는 이 오류를 받습니다.textAngular는 이 문제를 해결할 수 있는 이 메서드를 라이브러리에 가지고 있기 때문입니다.

프로젝트에서 textAngular-sanitize.js를 삭제하거나 아래와 같이 angular.module 로드 전에 Ovidiu Dolha 코드를 app.js에 포함할 수 있습니다.

angular.uppercase=function(text){
 return text.toUpperCase();
 }
 angular.lowercase=function(text){
 return text.toLowerCase();
 }

angular.module('sampleApp', ....)

오비디우 돌하가 준 암호는

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

라고 쓸 수 있다

angular.lowercase=function(text){
     return text.toLowerCase();
     }

둘 다 잘 될 거예요.감사해요.

오비디우 돌하의 대답에 거의 다 왔어요.의 폐지 전 실장을 보면,lowercase기능, 조금 더.이 SIM 구현은 다음과 같은 이점을 가져다 주었습니다.

/**
 * @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;

또 다른 적절한 솔루션은textAngular와 함께testAngularJs여기에 제시된 와 같이

npm install textangularjs

angular 1.7.5로 업데이트 했을 때도 같은 문제가 발견되어 angular-sanitize를 업데이트하여 문제가 해결되었습니다.각도로 편중하다

typescript와 linter(내 경우 tslint + standard)에 angularjs를 사용하는 경우 올바른 회피책은 다음과 같습니다.

if (!angular.lowercase) (angular as any).lowercase = (text: string) => angular.isString(text) ? text.toLowerCase() : text

Angular를 사용하고 있습니다.JS v1.7.5. 컨트롤러에서 다음 코드를 사용하여 문자열을 소문자로 변환했습니다.

function myCtrl($scope, $filter)
{
    var sampleText = "THIS IS TEST";
    var test = $filter('lowercase')(sampleText);
}

컨트롤러에 $filter를 삽입하고 동일한 값을 사용하여 소문자로 변환합니다.

언급URL : https://stackoverflow.com/questions/50448326/uncaught-typeerror-angular-lowercase-is-not-a-function

반응형