My one-page application has two controllers: the first for my main menu, the second for presentation. They exchange data with this factory
myApp.factory('MenuFactory', function(){ var factory = { Monitor: "doneJob", Control: "", Report: "", Display: "", setMonitor: function(value){ factory.Monitor = value; }, setControl: function(value){ factory.Control = value; }, setReport: function(value){ factory.Report = value; }, setDisplay: function(value){ factory.Display = value; } }; return factory; });
I would like to see the change on factory.Control , but I cannot get it to work.
When I try this:
$scope.$watch(function(){MenuFactory.Control}, function(NewValue, OldValue){ console.log(NewValue + ' ' + OldValue); console.log(MenuFactory.Control); }, true);
I get "undefined undefined" and "Process" in the console. Are there any problems with my $ watch implementation for this factory?
source share