EDIT - This only addresses the OP's misunderstanding of the problem, while @TongShen seems to have offered a solution to the actual problem.
I think you're conflating the concept of an app with that of a module.
Apps would tend to need some extra layer (e.g. an API) to communicate with one another, so if what you demonstrated were apps, then yes, you might have a problem.
Instead, your code demonstrates the use of modules, which can be used extensively with Angular to help segment and encapsulate your code. Provided that each module is interfaced properly through use of dependency injection, they can access one another.
Here is a simple demonstration, loosely patterned from your code:
var myApp = angular.module('myApp', ['otherApp']);
var anotherModule = angular.module('otherApp', []);
myApp.factory('MyFactory', function(){
var stuff = {};
stuff.doSomething = function(){
console.log('just did something');
}
return stuff;
});
anotherModule.directive('myDirective', function(MyFactory){
return {
restrict: 'E',
link: function(){
MyFactory.doSomething();
}
}
});
... and you can see that the console.log
does fire in this Plunker.