我有一个带角度的.net项目。我正在尝试将角度热键(https://github.com/chieffancypants/angular-hotkeys/)添加到项目中并使用它。
然后我将热键添加到控制器中,它依赖于它,并尝试添加该函数。
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.....
答案 0 :(得分:1)
我认为您的问题出在您的控制器中。缺少热键依赖
defaults:
-
scope:
path: ""
type: "posts"
values:
layout: "default"