![](/img/trans.png)
[英]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.