[英]Adding a controller to my mean.js app seems to automatically fire an api call?
[英]Adding module “angular-hotkeys” to my mean.js app
刚开始使用棱角分明 - 所以希望我不会错过一些绝对明显的东西。 我正在使用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">
我知道我可能正在做一些非常简单的错误 - 但对于我的生活,我无法弄清楚它是什么。
这可能是因为模块被称为cfp.hotkeys
而不是hotkeys
,这意味着您在文件中加载了错误的模块名称。
请参阅此处定义的模块名称
更新:使用bower
而不是使用npm
安装模块,也不是全局安装。
bower install angular-hotkeys --save
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.