javascript - Angular js : $injector:modulerr Module Error

标签 javascript angularjs

这是我的 app.js

    (function () {

app = angular.module('alamak', ['ngAnimate', 'ui.bootstrap', 'ngTagsInput', 'uiSwitch', 'colorpicker.module', 'wysiwyg.module', 'angularjs-dropdown-multiselect'])
    }())

这是我的 Controller

 (function () {

var alamakCore = function ($scope, $http) {

    $scope.checklogin = function () {


        $http.get("http://localhost:2421/api/alamakCore/GETLogin")

           .success(function (res) {
               debugger;

               $scope.users = res;
               $scope.msg = "Nada";
               $("#notLogin").hide();
               $("#LoginTab").show();
               $("#userData").hide();
             //  $("#user_name").append(res.Username);
               $(".lvl1.UserPhoto").prepend("<img src='/Images/1-1.jpg'  class='img-responsive img-circle' /> ");
               $("#SideBarNotLogined").hide();

               $("#Searchtxt").on("keyup", function () {
                   var txt = $(this).val();
                   $("div[class='col-md-3 col-sm-6']").each(function () {
                       var sourcetxt = $(this).children("p[class='Home_SourceTitle']").text();
                       //var Newstxt = $(this).childeren("a[class='Home_NewsTitle']").text();
                       if (sourcetxt.toUpperCase().indexOf(txt.toUpperCase()) != -1) {
                           $(this).show();
                       }
                       else {
                           $(this).hide();
                       }
                   })
               })   
           })
    }

    $scope.checklogin();

     $scope.GetSubscription = function () {
         $http.get("http://localhost:2421/api/alamakCore/GetSubscribtions")
             .success(function (res) {
                 $scope.subscriptions = res;
             })
     }

     $scope.getMychannels = function () {        
         $http.get("http://localhost:2421/api/alamakCore/GetMyChannels")
        .success(function (res) {
            $scope.MyChannels = res;           
        })
    }

     $scope.GetGategories = function () {
         $http.get("http://localhost:2421/api/alamakCore/GetGategories")
            .success(function (res) {
                $scope.Gategories = res;
            })
     }

     $scope.GetNews_Login = function () {
         $http.get("http://localhost:2421/api/alamakCore/GetNews_Login")
            .success(function (res) {
                $scope.News = res;
            })
     }

    $scope.GetSubscription();
     $scope.GetGategories();
     $scope.getMychannels();
     $scope.GetNews_Login();

}

    angular.module("alamak").controller("alamakCore", alamakCore);

    }())

这是我的母版页和我使用它的链接

    <link rel="stylesheet" id="normalize-css" href="~/css/normalize.css?ver=1.0" media="all">
<script type="text/javascript" src="~/js/lib/conditionizr-4.3.0.min.js?ver=4.3.0"></script>
<script type="text/javascript" src="~/js/lib/modernizr-2.7.1.min.js?ver=2.7.1"></script>
<script type="text/javascript" src="~/js/lib/jquery.js"></script>
<script src="~/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="~/js/lib/jquery-migrate.min.js"></script>
<link href="~/css/angular-ui-switch.css" rel="stylesheet" />
<script src="~/js/angular.min.js"></script>
<script src="~/js/angular-route.js"></script>
<script src="~/js/angular-animate.js"></script>     
<script src="~/js/ui-bootstrap-tpls-1.3.3.min.js"></script>
<script src="~/app/app.js"></script>
<script src="~/app/JsControllers/3alamkCoreController.js"></script>

我在 body 标签中调用 ng-app 和 ng-controller 然后我在浏览器中收到此错误

    Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.5/$injector/modulerr?p0=alamak&p1=Error%3A%…at%20c%20(http%3A%2F%2Flocalhost%2F3alamak%2Fjs%2Fangular.min.js%3A21%3A19)

我的 Angular 更大,所以我找不到丢失的代码在哪里

最佳答案

错误提示没有模块alamak。这是因为您没有创建它,您只是在创建它之前尝试获取它。

下面是 getter 的示例:

// This is a getter and requires a module that's already
// been created or an error will be thrown.
var module = angular.module('alamak')

您需要的是以下内容:

// Create a new module 'alamak' that takes a second parameter
// that is an array of dependencies.
angular.module('alamak', []);

关于javascript - Angular js : $injector:modulerr Module Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37640953/

相关文章:

javascript - 使用 Angular.js 查找正在进行的 http get 请求的下载状态

javascript - HTML5 Canvas 和 JS 帧率慢慢降至 0

javascript - 替换 Canvas 中的特定颜色及其阴影

javascript - ng-repeat 仅显示最后一项

javascript - 使用服务的输出到 Controller

javascript - 在 angular.js 应用程序中维护页面刷新时的客户端页面状态

javascript - 如何用一个值函数设置多个属性?

javascript - 使用respond_to 做 |format| format.js 在模态中收藏照片后在模态中显示消息?

javascript - AngularJS 多重解析

javascript - 为什么拼接方法有这种奇怪的行为?