Skip to content

Instantly share code, notes, and snippets.

@terakilobyte
Created January 13, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terakilobyte/4fbcfd1db617b7df8f8a to your computer and use it in GitHub Desktop.
Save terakilobyte/4fbcfd1db617b7df8f8a to your computer and use it in GitHub Desktop.
/**
* Angular API Call
*/
exports.getAccountAngular = function(req, res) {
Challenge.find({}, null, { sort: { challengeNumber: 1 } }, function(err, c) {
if (err) {
console.error('Challenge err: ', err);
next(err);
}
res.json({
user: req.user
});
});
};
/**
* Async user data request
*/
profileValidation.controller('profileValidationController', ['$scope', '$http',
function($scope, $http) {
$http.get('/account/api').success(function(data) {
$scope.user = data.user;
$scope.user.profile.username = $scope.user.profile.username ? $scope.user.profile.username.toLowerCase() : undefined;
$scope.storedUsername = data.user.profile.username;
$scope.storedEmail = data.user.email;
$scope.user.email = $scope.user.email ? $scope.user.email.toLowerCase() : undefined;
$scope.user.profile.twitterHandle = $scope.user.profile.twitterHandle ? $scope.user.profile.twitterHandle.toLowerCase() : undefined;
$scope.asyncComplete = true;
});
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment