I have two different ng-app running on same page.
- bookingApp
- calendarApp
I want to share selected date scope variable from calendarApp to bookingApp. How I can achieve this functionality?
Thanks, Gladiator
You have to use angularjs service for this purpose.Hope the following implementation will help you to get some understanding
angular.module('app.A', [])
.service('ServiceA', function() {
this.getValue = function() {
return this.myValue;
};
this.setValue = function(newValue) {
this.myValue = newValue;
}
});
angular.module('app.B', ['app.A'])
.service('ServiceB', function(ServiceA) {
this.getValue = function() {
return ServiceA.getValue();
};
this.setValue = function() {
ServiceA.setValue('New value');
}
});
You can share data between Angular apps by Window postMessage and / or localStorage.
Just wrap postMessave into Angular Service and propagate changes on post event.
ng-apps?