How does dpendency injection in mean.io work. As per the docs http://learn.mean.io/#mean-packages-dependency-injection.
I created two packages pkg1 and pkg2. In my pkg2 app.js file I have
Pkg2.register(function(app, auth, database,Pkg1) {
Pkg2.routes(app, auth, database);
Pkg2.menus.add({
title: 'pkg2 example page',
link: 'pkg2 example page',
roles: ['authenticated'],
menu: 'main'
});
Pkg2.aggregateAsset('css', 'pkg2.css');
return Pkg2;
});
But I get this error when i start the application
Error: dependency 'Pkg1' was not registered
Pkg1 is registered using the following code
Pkg1.register(function(app, auth, database) {
Pkg1.routes(app, auth, database);
Pkg1.menus.add({
title: 'pkg1 example page',
link: 'pkg1 example page',
roles: ['authenticated'],
menu: 'main'
});
Pkg1.aggregateAsset('css', 'pkg1.css');
return Pkg1;
});
Both packages are created using commands
mean package pkg1
mean package pkg2
When you have two packages, you can use one package in another as below.
In the Pk1, you can register the package:
Then you can use the pk1 in your second package.
Make sure you use pk1, not Package1. Otherwise, the meanio package system give you the package not registered error.