philippd/angular-deferred-bootstrap — pull request #16 by Shepless (2014-08-01 12:07:27+00:00)
Title: Added ability to specify which module a constant is added to

This PR allows users to specify which module a constant should be attached to, using the following syntax:

```js
window.deferredBootstrapper.bootstrap({
element: document.body,
module: 'MainApp',
moduleResolves: [
{
module: 'MainApp.Constants',
resolve: {
CONSTANT_ONE: ['$http', function ($http) {
return $http.get();
}],
CONSTANT_TWO: ['$http', function ($http) {
return $http.get();
}]
}
},
{
module: 'MainApp.MoreConstants',
resolve: {
ANOTHER_CONSTANT: ['$http', function ($http) {
return $http.get();
}]
}
}
]
})
```

In the example above, ```CONTANT_ONE``` and ```CONSTANT_TWO``` will be added to the ```MainApp.Constants``` module and ```ANOTHER_CONSTANT``` will be added to the ```MainApp.MoreConstants``` module. Notice above that x amount of constants can be added to a module, the user is not limited in this respect.

To minimise impact I have re-used the exact same approach to calling the resolve functions but wrapped in additional ```forEach``` loops.

For simplicity a user can only specify either the standard resolve **OR** the moduleResolves options. The following would throw an exception whilst checking the config:

```js
window.deferredBootstrapper.bootstrap({
element: document.body,
module: 'MainApp',
resolve: {
FOO: ['$http', function ($http) {
return $http.get();
}]
},
moduleResolves: [
{
module: 'MainApp.Constants',
resolve: {
CONSTANT_ONE: ['$http', function ($http) {
return $http.get();
}]
}
}
]
})
```

I've added a few unit tests for config checking and also to ensure constants get added to the correct modules.

Let me know if this meets the requirements, if not I'll go back to the drawing board.

Cheers