添加模块"角度热键"到我的mean.js应用程序

时间:2014-09-07 03:57:10

标签: angularjs node.js hotkeys mean-stack meanjs

刚刚开始使用棱角分明 - 所以希望我不会错过一些绝对明显的东西。我正在使用mean.js(Mongo,Express,Angular,Node堆栈)并开发一个简单的应用程序来启动我。我正在尝试将angular-hotkeys模块添加到我的应用中。

我使用sudo npm install -g angular-hotkeys --save

安装了模块

然后我将ApplicationConfiguration.registerModule('cfp.hotkeys');添加到我的core.client.module.js文件中。

在我的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'];

最后 - 我将热键绑定到我的控制器:

// 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');

但是每次加载页面时都会出现以下错误:

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">

我知道我可能做了一件非常简单的错事 - 但对于我的生活,我无法弄清楚它是什么。

1 个答案:

答案 0 :(得分:1)

这可能是因为模块被称为cfp.hotkeys而不是hotkeys,这意味着您在文件中加载了错误的模块名称。

查看已定义的模块名称here

更新:使用bower而不是使用npm安装模块,也不使用全局安装模块。

bower install angular-hotkeys --save