Skip to content

Instantly share code, notes, and snippets.

@goyalrohit
Created January 17, 2018 09:19
Show Gist options
  • Save goyalrohit/0bcf3891c0175a1109f6b5a0bf2b57fb to your computer and use it in GitHub Desktop.
Save goyalrohit/0bcf3891c0175a1109f6b5a0bf2b57fb to your computer and use it in GitHub Desktop.
Angular Value Function
(function () {
angular.module('app')
.value('badgeService', {
retrieveBadge: retrieveBadge
});
function retrieveBadge(minutesRead) {
var badge = null;
switch (true) {
case (minutesRead > 5000):
badge = 'Book Worm';
break;
case (minutesRead > 2500):
badge = 'Page Turner';
break;
default:
badge = 'Getting Started';
}
return badge;
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment