I managed to successfully pass a value from one AngularJS module to another using the .value method.
Here is an example of it working:
var app = angular.module('app', []);
app.value('movieTitle', 'The Matrix');
var app1 =angular.module('app1', ['app']);
app1.controller('MyController', function (movieTitle) {
//I am able to retrieve the value without any issues.
console.log(movieTitle)
})
However, there was an issue when trying to update the value:
var app = angular.module('app', []);
app.value('movieTitle', 'The Matrix');
app.controller('MyController', function (movieTitle) {
//I tried to change the value here.
movieTitle = "The Matrix Reloaded";
})
var app1 =angular.module('app1', ['app']);
app1.controller('MyController', function (movieTitle) {
//When accessing the value from another module, only the old value is displayed.
console.log(movieTitle)
})
In the second scenario, I attempted to update the value successfully. However, when attempting to access the updated value from a different module, it still showed the old value. Can anyone assist in identifying where the mistake might be?