【发布时间】:2017-06-02 17:35:46
【问题描述】:
我有一个带有角度的 .net 项目。我正在尝试将 angular-hotkeys (https://github.com/chieffancypants/angular-hotkeys/) 添加到项目中并使用它。
我使用 nuget 将其添加到项目中,并将其添加到我的包中。
然后我将热键添加到需要依赖项的控制器并尝试添加功能。
angular.module('mainApp')
.controller('ndcController', ["$scope", "$location", "$timeout", "fieldService", "entityService", "$filter", "authorizedUserService", "$q", "gerimedService", function ($scope, $location, $timeout, fieldService, entityService, $filter, authorizedUserService, $q, gerimedService,hotkeys) {
hotkeys.add({
combo: 'ctrl+up',
description: 'This one goes to 11',
callback: function () {
var test = "";
}
});
}]);
页面只是挂起加载,Ajax 永远不会完成。如果我删除函数 (hotkeys.add()),即使添加了热键依赖项,页面也会加载。
我还在 BundleConfig.cs 中添加了依赖项:
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-1.12.2.js",
"~/Scripts/modernizr-2.6.2.js",
"~/Scripts/respond.js",
"~/Scripts/angular.js",
"~/Scripts/angular-route.js",
"~/Scripts/angular-animate.js",
"~/Scripts/knockout-3.1.js",
"~/Scripts/knockout.mapping-latest.js",
"~/JavaScript/validateNumberInput.js",
"~/JavaScript/Accounting.js",
"~/Scripts/jquery-ui-1.8.24.js",
//"~/Scripts/jquery.validate.js",
"~/Scripts/moment.js",
"~/Scripts/bootstrap.js",
"~/Scripts/bootstrap-datepicker.js",
"~/Scripts/hotkeys.js",
"~/Scripts/mask.js"//below is my code
//"~/JavaScript/Module/Module.js",
//"~/JavaScript/Filters/Filters.js",
//"~/JavaScript/Services/Services.js",
//"~/JavaScript/Directives/Directives.js",
//"~/JavaScript/Controllers/HomeControllers.js"
));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
//bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
// "~/Scripts/modernizr-*"));
//,"~/Content/site.css"
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css", "~/Content/site.css", "~/Content/hotkeys.css"
));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.slider.css",
"~/Content/themes/base/jquery.ui.tabs.css",
"~/Content/themes/base/jquery.ui.datepicker.css",
"~/Content/themes/base/jquery.ui.progressbar.css",
"~/Content/themes/base/jquery.ui.theme.css"));
//bundles.Add(new ScriptBundle("~/js/app").Include("~/JavaScript/ApprovalsDisplay.js"));
BundleTable.EnableOptimizations = false;
}
}
我做错了什么,我该如何解决?
编辑:控制台错误:
"Error: [$injector:unpr] Unknown provider: hotkeysProvider <- hotkeys
http://errors.angularjs.org/1.2.28/$injector/unpr?p0=cfp.hotkeysProvider%20%3C-%20cfp.hotkeys
minErr/<@http://localhost:51059/Scripts/angular.js:78:12.....
【问题讨论】:
标签: javascript .net angularjs