【发布时间】:2016-05-12 01:54:26
【问题描述】:
我一直在尝试在 meanJS 文件夹结构中安装 Angular 指令。但是在尝试将指令添加到我的控制器时出现错误。
错误:[$injector:unpr] 未知提供者:duScrollProvider http://errors.angularjs.org/1.3.20/$injector/unpr?p0=duScrollProvider%20%3C-NaNuScroll%20%3C-%20HomeController 在http://localhost:3000/lib/angular/angular.js:63:12 在http://localhost:3000/lib/angular/angular.js:4031:19 在 Object.getService [as get] (http://localhost:3000/lib/angular/angular.js:4178:39) 在http://localhost:3000/lib/angular/angular.js:4036:45 在 getService (http://localhost:3000/lib/angular/angular.js:4178:39) 在 Object.invoke (http://localhost:3000/lib/angular/angular.js:4210:13) 在extend.instance (http://localhost:3000/lib/angular/angular.js:8516:21) 在http://localhost:3000/lib/angular/angular.js:7762:13 在 forEach (http://localhost:3000/lib/angular/angular.js:334:20) 在 nodeLinkFn (http://localhost:3000/lib/angular/angular.js:7761:11)
我要安装的指令是:https://github.com/oblador/angular-scroll
我使用的是 0.4.2 版
不过,我也尝试过其他“滚动”指令,但得到了同样的错误。
我正在尝试将它添加到我的 home.client.controller.js 中,如下所示:
angular.module('core').controller('HomeController', ['$scope', 'Authentication', 'duScroll', function ($scope, Authentication, duScroll) {
我也尝试将它添加到核心的末尾。
angular.module('core', ['duScroll']).controller('HomeController', ['$scope', 'Authentication', function ($scope, Authentication) {
至于下面的答案我也试过了。
我在 config/assets/default.js 中的 default.js 文件中添加了 'public/lib/angular-scroll/angular-scroll.js'
我还在 config.js 中添加了 duScroll,位于:modules/core/client/app/config.js
var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ui.utils', 'angularFileUpload', 'duScroll'];
但是我仍然遇到同样的错误。
所有文档都说我应该使用 bower install 或 npm install 来安装这些指令。但由于它是一个模块化的文件夹结构,我不知道如何让它识别指令。我已经尝试在我能想到的所有地方都包含它。
任何帮助弄清楚如何在 meanjs 文件夹结构中安装指令将不胜感激!
谢谢
【问题讨论】:
标签: angularjs angularjs-directive meanjs