我开发了一个小应用程序,现在我想第一次将其发布到azure。
这是我第一次在任何项目中使用 Angular,但我遇到了一些问题。 我收到此错误:
错误:[$injector:unpr] 未知提供者:sProvider <- s <- MapController
这是我的 Controller :
var app = angular.module("TravelPlanner", []);
var mapController = function ($scope, $http) {
lots of functions....
}
app.controller("MapController", mapController);
这是我的布局页面:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/kendo/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyASli52h7eL3W1CSNtTrl-S71zDFATqbDg&libraries=places"></script>
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/kendo")
<script src="~/ckeditor/ckeditor.js"></script>
@*<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script src="~/Scripts/plugin.min.js"></script>*@
</head>
<body ng-app="TravelPlanner">
<div class="container body-content" ng-controller="MapController">
@RenderBody()
</div>
@RenderSection("scripts", required: false)
</body>
为什么会出现这个 Angular 误差?
** 编辑 ** 这是我加载脚本的包。
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js",
"~/Scripts/Angular.js",
"~/Scripts/DropZone.js",
"~/Content/Scripts/gmaps.js",
"~/Content/Scripts/jquery.geocomplete.min.js",
"~/Scripts/jquery-ui-1.11.4.min.js",
"~/Content/Scripts/MapController.js",
"~/Content/Scripts/sweetalert.min.js"
));
mapcontroller.js 是我所有 Angular/js 代码所在的位置。 (不知道为什么我没有更改 bundle 的名称,我猜我太懒了)
最佳答案
你需要注释你的mapController依赖
var mapController = ['$scope', '$http', function ($scope, $http) {
lots of functions....
}];
查看此链接:https://docs.angularjs.org/guide/di#dependency-annotation
关于c# - 发布网站时出现 Angular 未知提供商错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34687705/