Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create module per component/service #2

Open
SamVerschueren opened this issue Feb 24, 2016 · 1 comment
Open

Create module per component/service #2

SamVerschueren opened this issue Feb 24, 2016 · 1 comment

Comments

@SamVerschueren
Copy link
Owner

At the moment, we only have one global module where all the services, components, ... are defined in. This is not entirely correct. If we have this tree

- A
  |--- B
  |--- C
       |--- D

Where D is defined like this

@Component({
    providers: [C]
})
class D {
    constructor(private c: C) {

    }
}

D only should be available for all the children of C. But because they are now placed in the global module, D will also be available for B.

Solution

Create an angular.module() per component, service, ... Inject the modules accordingly.

For the example above, it would look like.

const aModule = angular.module('A', []);
const bModule = angular.module('B', []);
const dModule = angular.module('D', []);
const cModule = angular.module('C', ['D']);

which will limit the usage of D to everything inside the C module.

@SamVerschueren SamVerschueren added this to the v0.1.0 milestone Feb 26, 2016
@SamVerschueren
Copy link
Owner Author

This doesn't work because angular 1 only has one DI, unless we would implement our own DI system.

@SamVerschueren SamVerschueren removed this from the v0.1.0 milestone Apr 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant