[英]Adding module “angular-hotkeys” to my mean.js app
Just getting started with angular - so hoping I am not missing something absolutely obvious. 刚开始使用棱角分明 - 所以希望我不会错过一些绝对明显的东西。 I am using mean.js (Mongo, Express, Angular, Node stack) and working on a simple to do app to get me started.
我正在使用mean.js(Mongo,Express,Angular,Node堆栈)并开发一个简单的应用程序来启动我。 I am trying to add the angular-hotkeys module to my app.
我正在尝试将angular-hotkeys模块添加到我的应用程序中。
I installed the module using sudo npm install -g angular-hotkeys --save
我使用
sudo npm install -g angular-hotkeys --save
安装了模块
I then added ApplicationConfiguration.registerModule('cfp.hotkeys');
然后我添加了
ApplicationConfiguration.registerModule('cfp.hotkeys');
to my core.client.module.js file. 到我的core.client.module.js文件。
And in my config.js file, I added cfp.hotkeys as a dependency: 在我的config.js文件中,我添加了cfp.hotkeys作为依赖项:
var ApplicationConfiguration = (function() {
// Init module configuration options
var applicationModuleName = 'taskmanager';
var applicationModuleVendorDependencies = ['ngResource', 'ngCookies', 'ngAnimate', 'ngTouch', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.utils', 'cfp.hotkeys'];
Finally - I bound hotkeys to my controller: 最后 - 我将热键绑定到我的控制器:
// Lists controller
angular.module('lists').controller('ListsController', ['$scope', '$stateParams', '$location', 'Authentication', 'Lists', 'SelectedList', 'hotkeys',
function($scope, $stateParams, $location, Authentication, Lists, SelectedList, hotkeys ) {
$scope.authentication = Authentication;
console.log('hotkeys');
But every time I load the page I get the following error: 但是每次加载页面时都会出现以下错误:
Error: [$injector:unpr] Unknown provider: hotkeysProvider <- hotkeys http://errors.angularjs.org/1.2.22/$injector/unpr?p0=hotkeysProvider%20%3C-%20hotkeys
at http://localhost:3000/lib/angular/angular.js:78:12
at http://localhost:3000/lib/angular/angular.js:3792:19
at Object.getService [as get] (http://localhost:3000/lib/angular/angular.js:3920:39)
at http://localhost:3000/lib/angular/angular.js:3797:45
at getService (http://localhost:3000/lib/angular/angular.js:3920:39)
at invoke (http://localhost:3000/lib/angular/angular.js:3947:13)
at Object.instantiate (http://localhost:3000/lib/angular/angular.js:3967:23)
at http://localhost:3000/lib/angular/angular.js:7260:28
at http://localhost:3000/lib/angular/angular.js:6651:34
at forEach (http://localhost:3000/lib/angular/angular.js:332:20) <section data-ui-view="" class="ng-scope">
I know I am probably doing something very simple wrong - but for the life of me I can't figure out what it is. 我知道我可能正在做一些非常简单的错误 - 但对于我的生活,我无法弄清楚它是什么。
That might be because the module is called cfp.hotkeys
not hotkeys
, that mean's you're loading the wrong module name in your file. 这可能是因为模块被称为
cfp.hotkeys
而不是hotkeys
,这意味着您在文件中加载了错误的模块名称。
See the name of module defined here 请参阅此处定义的模块名称
Update: Install the module using bower
instead of using npm
and also not globally. 更新:使用
bower
而不是使用npm
安装模块,也不是全局安装。
bower install angular-hotkeys --save
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.