Created
January 17, 2018 09:19
-
-
Save goyalrohit/0bcf3891c0175a1109f6b5a0bf2b57fb to your computer and use it in GitHub Desktop.
Angular Value Function
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
(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