Skip to content

ds.module

digital synapse edited this page Mar 3, 2015 · 5 revisions

ds.module( modulename, dependencies )

This function accepts a string that will be used to create or append to a module. Note: This is similar to module in angularJS. If you are using angular you should use angular.module() instead.

###Arguments

  • modulename <string>
    a unique name for this module

  • dependencies <array> (optional)
    this is the list of module dependencies

###Returns

  • module scope <object> the return object contains 2 functions
    • controller( name, dependencies )
    • factory( name, dependencies )

###Example Usage ds.module('ModuleUtils', []); // Define a new module // ... ds.module('Module', ['ModuleUtils']); // Define another module. Module has access to ModuleUtils // ... ds.module('Module') // Add thing to an existing module

Back to Home

.controller( name, dependencies )

This function accepts a string that will be used to create a controller. Note: This is similar to controller in angularJS. If you are using angular you should use the angular controller instead.

###Arguments

  • name <string>
    a unique name for this controller

  • dependencies <array>
    this is the list of controller dependencies.

###Returns

  • module scope <object> the return object contains 2 functions
    • controller( name, dependencies )
    • factory( name, dependencies )

###Example Usage ds.module('Test',[])

.factory('Child', [function() {
    return 'I am a dependency of Parent';
}]);
.controller('Parent', ['Child', function(Child) {
    alert(Child);
}]);

Back to Home

.factory( name, dependencies )

This function accepts a string that will be used to create a factory. Note: This is similar to factory in angularJS. If you are using angular you should use the angular factory instead.

###Arguments

  • name <string>
    a unique name for this factory

  • dependencies <array>
    this is the list of factory dependencies.

###Returns

  • module scope <object> the return object contains 2 functions
    • controller( name, dependencies )
    • factory( name, dependencies )

###Example Usage ds.module('Test',[])

.factory('Child', [function() {
    return 'I am a dependency of Parent';
}]);

.factory('Parent', ['Child', function(Child) {
    alert(Child);
}]);

Back to Home