我应该在mean.js中添加模块依赖项(用于ng-sortable) [英] where should I add module dependencies in mean.js (for ng-sortable)

查看:83
本文介绍了我应该在mean.js中添加模块依赖项(用于ng-sortable)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将ng-sortable添加到基于我的mean.js的应用程序中. https://github.com/a5hik/ng-sortable

I am trying to add ng-sortable to my mean.js based app. https://github.com/a5hik/ng-sortable

按照安装说明进行操作并使其适应于mean.js,我包括了js和css文件(它们已正确加载),但我失败的地方是添加了模块依赖项:

Following the install instructions and adapting them to mean.js I included the js and css files (which are loading correctly), but where I fall down is adding module dependencies:

然后将可排序模块作为依赖项注入.

And Inject the sortable module as dependency.

angular.module('xyzApp', ['ui.sortable', '....']);

我的angularjs控制器看起来像这样:

My angularjs controller looks like this:

var listers_mod = angular.module('listers');
listers_mod.controller('PagesController', ['$scope', '$http', '$stateParams', '$location',  'Authentication',
    function($scope, $http, $stateParams, $location, Authentication) { ... }
]);

我的第一次尝试是在上面的控制器文件中添加ui.sortable:

My first attempt was to add the ui.sortable in the controller file above:

var listers_mod = angular.module('listers', ['ui.sortable']);

显然这没有用.正如您可能会告诉我的那样,我对Mean.js和MEAN堆栈一般来说是一个新手,所以我在这个问题上迷失了脚步.我尝试了四处搜寻,当然也搜寻了这里,但没有找到对我有意义的答案.

Obviously this did not work. As you can probably tell I am very new to mean.js and the MEAN stack in general so I am stumbling around blind on this one. I tried googling around and of course searching here, but I didn't find any answers that made any sense to me.

欢迎任何帮助.

推荐答案

当我向基于mean.js的应用程序中添加新的Angular模块时,我将该模块添加到public目录中的config.js文件中.在将更多模块添加到项目中时,可以添加模块依赖项列表:

When I add a new Angular module to a mean.js based application, I add the module to the config.js file within the public directory. There is a list of module dependencies which you can add to as you add more modules to your project:

链接到源:
https://github.com/meanjs/mean/blob/f4b62ca8199227c6791d535bbf67bba5d2db91f0 js#L7

Link to source:
https://github.com/meanjs/mean/blob/f4b62ca8199227c6791d535bbf67bba5d2db91f0/public/config.js#L7

示例:

var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils'];

尝试将其添加到此处,而不要使用控制器中的var listers_mod = angular.module('listers');行.您可能根本不需要将其注入到控制器中-查看文档,将其添加到应用程序的模块列表后,您可以尝试以HTML代码访问它.

Try adding it there instead of using the var listers_mod = angular.module('listers'); line you have in your controller. You may not need to inject it into your controller at all -- looking at the documentation you could just try accessing it in the HTML code after you've added it to your application's module list.

这篇关于我应该在mean.js中添加模块依赖项(用于ng-sortable)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆