I am trying to add ng-sortable to my mean.js based app. https://github.com/a5hik/ng-sortable
我正在尝试将ng-sortable添加到我的mean.js应用程序中。 https://github.com/a5hik/ng-sortable
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:
按照安装说明并将它们调整为mean.js我包含了js和css文件(正确加载),但我倒下的地方是添加模块依赖项:
And Inject the sortable module as dependency.
并将可排序模块注入依赖项。
angular.module('xyzApp', ['ui.sortable', '....']);
My angularjs controller looks like this:
我的angularjs控制器看起来像这样:
var listers_mod = angular.module('listers');
listers_mod.controller('PagesController', ['$scope', '$http', '$stateParams', '$location', 'Authentication',
function($scope, $http, $stateParams, $location, Authentication) { ... }
]);
My first attempt was to add the ui.sortable in the controller file above:
我的第一次尝试是在上面的控制器文件中添加ui.sortable:
var listers_mod = angular.module('listers', ['ui.sortable']);
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和MEAN堆栈一般都很新,所以我在这个问题上瞎了。我试着在谷歌上搜索,当然在这里搜索,但我找不到任何对我有任何意义的答案。
Any help welcome.
欢迎任何帮助。
3 个解决方案
#1
9
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:
当我向基于mean.js的应用程序添加新的Angular模块时,我将模块添加到公共目录中的config.js文件中。在向项目添加更多模块时,可以添加一个模块依赖项列表:
Link to source:
https://github.com/meanjs/mean/blob/f4b62ca8199227c6791d535bbf67bba5d2db91f0/public/config.js#L7
链接到源:https://github.com/meanjs/mean/blob/f4b62ca8199227c6791d535bbf67bba5d2db91f0/public/config.js#L7
Example:
var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils'];
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.
尝试在那里添加它而不是使用var listers_mod = angular.module('listers');您在控制器中的行。您可能根本不需要将它注入控制器 - 查看文档,您可以在将其添加到应用程序的模块列表后尝试在HTML代码中访问它。
#2
3
Base on dylants's answer, found the configuration file path has been changed to this file
根据dylants的答案,发现配置文件路径已更改为此文件
modules/core/client/app/config.js
I'm using meanjs-version 0.4.2, adding the new module into applicationModuleVendorDependencies works for me.
我使用的是meanjs-version 0.4.2,将新模块添加到applicationModuleVendorDependencies中对我有用。
#3
1
You can put dependencies as a second parameter of ApplicationConfiguration.registerModule function.
您可以将依赖项作为ApplicationConfiguration.registerModule函数的第二个参数。
Example, put timer in your module:
例如,在您的模块中放置计时器:
public/modules/your-module/your-module.client.module.js:
ApplicationConfiguration.registerModule('your-moduler', ['timer']);
#1
9
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:
当我向基于mean.js的应用程序添加新的Angular模块时,我将模块添加到公共目录中的config.js文件中。在向项目添加更多模块时,可以添加一个模块依赖项列表:
Link to source:
https://github.com/meanjs/mean/blob/f4b62ca8199227c6791d535bbf67bba5d2db91f0/public/config.js#L7
链接到源:https://github.com/meanjs/mean/blob/f4b62ca8199227c6791d535bbf67bba5d2db91f0/public/config.js#L7
Example:
var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ui.router', 'ui.bootstrap', 'ui.utils'];
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.
尝试在那里添加它而不是使用var listers_mod = angular.module('listers');您在控制器中的行。您可能根本不需要将它注入控制器 - 查看文档,您可以在将其添加到应用程序的模块列表后尝试在HTML代码中访问它。
#2
3
Base on dylants's answer, found the configuration file path has been changed to this file
根据dylants的答案,发现配置文件路径已更改为此文件
modules/core/client/app/config.js
I'm using meanjs-version 0.4.2, adding the new module into applicationModuleVendorDependencies works for me.
我使用的是meanjs-version 0.4.2,将新模块添加到applicationModuleVendorDependencies中对我有用。
#3
1
You can put dependencies as a second parameter of ApplicationConfiguration.registerModule function.
您可以将依赖项作为ApplicationConfiguration.registerModule函数的第二个参数。
Example, put timer in your module:
例如,在您的模块中放置计时器:
public/modules/your-module/your-module.client.module.js:
ApplicationConfiguration.registerModule('your-moduler', ['timer']);