我正在使用AngularJS以及c#mvc。我有一个主页,用户输入一些数据,并将其传递到第二个模块,我使用这些数据进行处理和决定。我必须使用第二个模块中第一个模块中输入或更新的数据。有人可以帮我怎么实现吗?
希望以下的实现将有助于您得到一些了解。
- 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');
- }
- });