$watch not detecting changes in service variable
问题 I am new to angularjs and I am facing this strange problem where $watch is not firing on change of a variable in service. I don't know where I have made a mistake. Plunkr: Link to Plunkr script.js file: var app = angular.module("app", []); app.factory("loggedInUser", [loggedInUser]); function loggedInUser() { var currentLoggedInUser = undefined; setTimeout(function() { currentLoggedInUser = "Karthik"; console.log("Updated user name"); }, 3000); return { getLoggedInUser: function() { return