programing

AngularJS 1.2$injector: 모듈러

minecode 2022. 9. 22. 21:18
반응형

AngularJS 1.2$injector: 모듈러

1.07 대신 angular 1.2를 사용하는 경우 다음 코드는 더 이상 유효하지 않습니다. 이유는 무엇입니까?

'use strict';

var app = angular.module('myapp', []);

app.config(['$routeProvider', '$locationProvider',
    function($routeProvider, $locationProvider) {
        $locationProvider.html5Mode(true);
        $routeProvider.
        when('/', {
            templateUrl: 'part.html',
            controller: 'MyCtrl'
        }).
        otherwise({
            redirectTo: '/'
        });
    }
]);

이 문제는 인젝터 설정 부분(app.config)에 있습니다.

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.0rc1/$injector/modulerr?p0=muninn&p1=Error%…eapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.0rc1%2Fangular.min.js%3A31%3A252) 

내 기억이 맞다면 이 문제는 각진 1.1.6에서 시작되었다.

이 문제는 ngRoute 모듈이 포함되어 있지 않기 때문에 발생했습니다.버전 1.1.6 이후로는 별도의 부품입니다.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>

var app = angular.module('myapp', ['ngRoute']);

마지막에 '()'를 추가함으로써 오류가 사라졌습니다.

(function(){
    var home = angular.module('home',[]);

    home.controller('QuestionsController',function(){
        console.log("controller initialized");
        this.addPoll = function(){
            console.log("inside function");
        };
    });
})();

목록에 추가할 것이 하나 더 있습니다. 이는 'Error: [$injector: modulerr] angular'의 구글 검색 결과가 처음 표시되기 때문입니다.

index'html'의 앱 이름과 기본 javascript 앱 정의의 앱 이름이 일치하지 않는 경우에도 이 오류가 발생할 수 있습니다.

예를 들어 HTML이 다음과 같은 경우:

    </head>
    <body ng-app="myWebSite">

        <!-- My Web Site -->
        <p>About my web site...</p>

        etc ...

그리고 당신의 JavaScript는 다음과 같습니다(예를 들어 myWebSite가 아닌 myWebCite 앱 이름에 오타가 있습니다).

/** Main AngularJS Web Application */ 
var app = angular.module('myWebCite', [ 'ngRoute' ]); 

/** Configure the Routes */ 
app.config(['$routeProvider', function ($routeProvider) { 
  etc ...

에러:[$syslog:modulerr] angular' 오류도 생성됩니다.

noob 오류가 모듈 js를 포함하는 것을 잊었을 수 있습니다.

<script src="app/modules/myModule.js"></script>

index.displaces에 있는 파일입니다.

에 이 가 있는 ([$injector:nomod], MINERR_ASSET:22)로딩하기 되어 있지 AngularJS

그렇게 하고 있었는데 주문을 고치고 나니 오류가 사라졌어요.

파일을 압축, 번들 및 최소화하는 프레임워크를 사용하는 경우 이러한 프레임워크가 변수 이름을 변경하는 경향이 있으므로 각 종속성을 명시적으로 정의해야 합니다.ASP の asp asp asp asp 。 물 netBundleConfig.cs앱 스크립트를 번들로 정리합니다.

전에

app.config(function($routeProvider) {
    $routeProvider.
      when('/', {
          templateUrl: 'list.html',
          controller: 'ListController'
      }).
      when('/items/:itemId', {
          templateUrl: 'details.html',
          controller: 'DetailsController'
      }).
      otherwise({
          redirectTo: '/'
      });
});

끝나고

app.config(["$routeProvider", function($routeProvider) {
    $routeProvider.
      when('/', {
          templateUrl: 'list.html',
          controller: 'ListController'
      }).
      when('/items/:itemId', {
          templateUrl: 'details.html',
          controller: 'DetailsController'
      }).
      otherwise({
          redirectTo: '/'
      });
}]);

각도 종속성 주석에 대한 자세한 내용은 여기를 참조하십시오.

에러가 했는데, 저에는 에러의 두 입니다.제 경우는 의 두 번째 파라미터에 의해 발생하였습니다.angular.module실종-이것이 같은 문제를 가진 누군가에게 도움이 되길 바랍니다.

angular.module('MyApp');

angular.module('MyApp', []);

add to link
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular-route.min.js"></script>

var app = angular.module('apps', [ 'ngRoute' ]); 

저도 같은 문제가 있어서 가능한 모든 해결책을 시도해 봤어요. 나는 알 수 .ngRoute모듈이 분리되었습니다.링크를 보세요.

솔루션:angular.min.js 스크립트 에 cdn angular-route.js를 추가합니다.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>

이 에러의 또 다른 트리거는 루트 정의의 "다른" 루트 또는 다른 루트 앞에 "."를 두는 것입니다.

  app.config(['$routeProvider',
     function($routeProvider) {
        $routeProvider.
           when('/view1', {
              templateUrl: 'partials/view1.html',
              controller: 'Ctrl1'
           }).
           otherwise({
              redirectTo: '/viewCounts'
           });
     }]);

또 한 번 풀스톱에 굴욕감을 느꼈어JS를 사랑해야지!

답변 외에 (「」 「」 「」 「」 「」[$injector:nomod],MINERR_ASSET:22모든 것이 정상적으로 동작하고 있는 것 같습니다.인덱스에 중복된 include가 없는지 확인해 주세요.

이 오류는 이 모듈을 사용하는 파일이 중복되어 있고 실제 모듈 선언이 있는 파일 앞에 포함되어 있는 경우에도 발생할 수 있습니다.

angularjs의 공식 튜토리얼을 참조하면 https://docs.angularjs.org/tutorial/step_07

주의: 각도부터 시작합니다.JS 버전 1.2, ngRoute는 자체 모듈에 있으며 위의 Bower를 통해 다운로드한 추가 angular-route.js 파일을 로드하여 로드해야 합니다.

또한 ngRoute api https://docs.angularjs.org/api/ngRoute에서 확인하십시오.

설치 첫 번째 HTML에 angular-route.js를 포함합니다.

이 파일은 다음 위치에서 다운로드할 수 있습니다.

Google CDN(예: //ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-route.js Bower 설치: angular-route@X)Y.Z code.angularjs.org (예: "//code.angularjs.org/X.Y.Z/angular-route.js" (X)Y.Z는 각도입니다.실행 중인 JS 버전입니다.

그런 다음 종속 모듈로 추가하여 응용 프로그램에 모듈을 로드합니다.

angular.module('app', 'ngRoute'); 이것으로 시작할 준비가 되었습니다.

John Papa는 이 다소 애매한 코멘트에 대한 나의 문제를 제공했습니다: 때때로 당신이 그 오류를 받았을 때, 그것은 당신이 파일을 놓쳤다는 것을 의미합니다.다른 경우에는 모듈이 사용된 후 정의되었음을 의미합니다. 이 문제를 쉽게 해결하는 방법 중 하나는 모듈 파일 이름을 *.module.js로 지정하고 먼저 로드하는 것입니다.

인젝터 오류입니다.JavaScript 파일을 많이 사용했기 때문에 인젝터가 누락되었을 수 있습니다.

여기도 있습니다.

var app = angular.module('app', 
    ['ngSanitize', 'ui.router', 'pascalprecht.translate', 'ngResource', 
     'ngMaterial', 'angularMoment','md.data.table', 'angularFileUpload', 
     'ngMessages', 'ui.utils.masks', 'angular-sortable-view',          
     'mdPickers','ngDraggable','as.sortable', 'ngAnimate', 'ngTouch']
);

해야 할 하세요.app.js

문제는 config.xml에 있었습니다.변경:

<access origin="*" launch-external="yes"/>

로.

<access origin="*"/>

고쳤습니다.

프로젝트 간에 전환하여 같은 포트에서 프로젝트를 차례로 실행할 때 이 오류가 발생하는 경우가 있습니다. Tools > 、 file file file file file file file file file file file js 파일을 되어 있는 곳은 Chrome Developer Tools > Network 입니다.if the file match with the workspce를 해결하려면 을 Disable Cache트워워네

몇 달 후 AngularJS (1.6.4) 앱을 개발하기 위해 돌아왔고, 개발 중에 테스트 대상으로 Chrome (PC)와 Safari (MAC)를 선택했습니다. 코드는 IE 11.0.9600(Windows 7, 32비트)에서 $injector: modulerr Module Error($injector: 모듈 오류)라는 오류를 나타내고 있습니다.

조사 결과, 에러는 사용되고 있는 각 루프에 기인하고 있는 것이 판명되었습니다.그냥 모든 for Each 루프를 정상으로 대체하면, 그대로의 루프가 동작합니다.

기본적으로는 Angular가 아닌 IE11 문제(여기서 답변)였습니다.JS의 문제, 그러나 나는 여기에 이 답변을 넣고 싶다. 왜냐하면 제기된 예외가 Angular이기 때문이다.JS 예외우리 중 몇 명에게 도움이 되었으면 좋겠어요.

비슷하게 람다 함수는 사용하지 마세요()=>{...}만 바꿔주세요.}이(가) 양호한 ol' function(){...}

나는 이 문제가 있었고 내 코드를 한 줄씩 확인한 후 이것을 보았다.

 <textarea class="form-control" type="text" ng-model="WallDesc" placeholder="Enter Your Description"/>

그냥 바꿨어요

     <textarea class="form-control" type="text" ng-model="WallDesc" placeholder="Enter Your Description"></textarea>

효과가 있었어요태그를 확인해 보세요.

언급URL : https://stackoverflow.com/questions/18287482/angularjs-1-2-injectormodulerr

반응형