简体   繁体   English

错误:$ injector:modulerr模块角度错误

[英]Error: $injector:modulerr Module Error in angular

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

    myapp.config(function($interpolateProvider) {
      $interpolateProvider
        .startSymbol('{[')
        .endSymbol(']}');
    });

    myapp.controller('CanvasControls', function($scope) {
        function1($scope);
        function2($scope);
     });

    This code integrate with rails and working in development fine but in production mode it gives below errors.

Failed to instantiate module myapp due to: 由于以下原因,无法实例化模块myapp:

Uncaught Error: $injector:modulerr 

/$injector/modulerr?p0=myapp / $喷油器/ modulerr?P0 = MYAPP

working in development fine but in production mode it gives below errors 在开发环境中正常工作,但在生产模式下会出现以下错误

Guess in production you are compressing the code.And I presume you have to add $scope like this Hope this will help 猜测在生产中您正在压缩代码。我想您必须像这样添加$scope希望这会有所帮助

// Changed here Added String '$scope'
    myapp.controller('CanvasControls',['$scope', function($scope) { 
            function1($scope);
            function2($scope);
         }]);

EDIT 编辑

If you have not modified the .config part please try by making following change. 如果您尚未修改.config部分,请尝试进行以下更改。

customInterpolationApp.config(['$interpolateProvider', function($interpolateProvider){
 $interpolateProvider.startSymbol('//');
    $interpolateProvider.endSymbol('//');
}]);

More about such error 有关此类错误的更多信息

Syntax error added extra ] in controller 语法错误在控制器中添加了额外的]

myapp.controller('CanvasControls', function($scope) {
     function1($scope);
     function2($scope);
}]);// remove ']' from here

or use mini-fist way 或用小拳头的方式

myapp.controller('CanvasControls', ['$scope',function($scope) {
     function1($scope);
     function2($scope);
}]);

and you may mismatch module name myapp in controller and in html ng-app="myapp" 并且您可能在控制器和html ng-app="myapp" myapp模块名称myapp不匹配

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM