So I have a routine that needs to run with user data that is retrieved at the initialization of the app.
My controller for the home page checks to see if there's a token in storage (a logged-in user) and then either runs the routine if $scope.currentUser already exists, or places a watch on it for when the AJAX call returns that data.
But the $watch callback is never triggered after its initialization.
Here's the Feed Controller code
if (sessionStorage.getItem('token'))
{
if ($scope.currentUser) {getItems()}
else {$scope.$watch('currentUser', popFeed()) }
}
function delayForUser()
{
if ($scope.currentUser) {popFeed()}
}
And the Application Controller code
if (sessionStorage.getItem('token') && sessionStorage != 'null')
{
UserSvc.getUser()
.then(function (response)
{
$scope.currentUser = response.data
})