这是我的app.js
(function () {
app = angular.module('alamak', ['ngAnimate', 'ui.bootstrap', 'ngTagsInput', 'uiSwitch', 'colorpicker.module', 'wysiwyg.module', 'angularjs-dropdown-multiselect'])
}())
这是我的控制器
(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)
我的角度更大,所以我找不到丢失的代码
答案 0 :(得分:1)
错误是抱怨没有模块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', []);