Last active
December 20, 2015 15:08
-
-
Save dchuk/6151684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
serpIQ.factory('UserAccount', ['$resource', '$timeout', function($resource, $timeout) { | |
var userResource = $resource('/users/account', {}, {}); | |
var accountInfo = {}; | |
(function pollStatus() { | |
userResource.get({}, function(response){ | |
accountInfo = { | |
plan: response.plan, | |
limits: response.limits, | |
usage_remaining: response.usage_remaining, | |
feature_limits: response.feature_limits, | |
created_at: response.created_at | |
}; | |
}); | |
$timeout(pollStatus, 10000); | |
})(); | |
return accountInfo; | |
}]); | |
app.controller('HeaderController', ['$scope', 'UserAccount', function($scope, UserAccount) { | |
$scope.userAccount = UserAccount.account(); | |
$scope.$watch(UserAccount.account, function(newValue, oldValue, scope) { | |
if(newValue && newValue != oldValue){ | |
$scope.userAccount = UserAccount.account(); | |
} | |
}); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment