简体   繁体   中英

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. I am trying to add the angular-hotkeys module to my app.

I installed the module using sudo npm install -g angular-hotkeys --save

I then added ApplicationConfiguration.registerModule('cfp.hotkeys'); to my core.client.module.js file.

And in my config.js file, I added cfp.hotkeys as a dependency:

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.

See the name of module defined here

Update: Install the module using bower instead of using npm and also not globally.

bower install angular-hotkeys --save

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM