I am using AngularJS along with c# mvc. I have a home page where user enters some data and that should be passed to the second module where I use this data for processing and decisions. I have to use the data entered or updated in the first module within the second module. Can someone help me how to achieve this?
Approach: To share data between the controllers in AngularJS we have two main cases: Share data between parent and child: Here, the sharing of data can be done simply by using controller inheritance as the scope of a child controller inherits from the scope of the parent controller.
You can import MemberCardModule into AppModule directly. Or import into ShareModule and import ShareModule into AppModule. It is important to import Modules into AppModule. And then you can you MemberCardModule.
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'); } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With