In these situations, you thought that the documents would no longer help you, a very good way to learn is to look at the other modules of the finished assembly and see how others did it, how they designed the architecture and how they integrated them into their application.
Looking at what others have done, you should have at least a starting point.
For example, look at any angular ui module , and you will see many custom modules.
Some define only one directive , while others define more things .
Like @nXqd , the main way to create a module is:
// 1. define the module and the other module dependencies (if any) angular.module('myModuleName', ['dependency1', 'dependency2']) // 2. set a constant .constant('MODULE_VERSION', '0.0.3') // 3. maybe set some defaults .value('defaults', { foo: 'bar' }) // 4. define a module component .factory('factoryName', function() {}) // 5. define another module component .directive('directiveName', function() {}) ;// and so on
After defining your module, it is very easy to add components to it (without having to store your module in a variable):
And the integration part is pretty simple: just add it as a dependency on your application module ( here , how angular ui does it).
angular.module('myApp', ['myModuleName']);
gion_13 01 Oct '13 at 6:57 on 2013-10-01 06:57
source share