Where should I add module dependencies to mean.js (for ng-sortable)

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

Following the installation instructions and adapting them to mean.js, I included the js and css files (which load correctly), but where I drop the module dependencies are added:

And insert the sortable module as a dependency.

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

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) { ... } ]); 

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

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

Obviously, this did not work. As you probably can say that I am very new to mean.js and the MEAN stack in general, so I stumble on this blind. I tried to search and, of course, search here, but I did not find the answers that made any sense to me.

Any help is appreciated.

+5
source share
3 answers

When I add a new Angular module to the mean.js based application, I add the module to the config.js file in the public directory. There is a list of module dependencies that you can add when additional modules are added to the project:

Link to the source:
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 instead of using the string var listers_mod = angular.module('listers'); that you have in your controller. You may not need to enter it into your controller at all - looking at the documentation that you could just try to get to it in the HTML code after you added it to your list of application modules.

+8
source

Based on the response to dylants, the path to the configuration file was found, which was changed to this file

modules / kernel / client / application/config.js

I am using meanjs version 0.4.2, adding a new module to applicationModuleVendorDependencies for me.

+3
source

You can put dependencies as the second parameter of the ApplicationConfiguration.registerModule function.

Example: put a timer in your module:

public / modules / your-module / your-module.client.module.js:

 ApplicationConfiguration.registerModule('your-moduler', ['timer']); 
+1
source

Source: https://habr.com/ru/post/1207703/


All Articles