Skip to content

Instantly share code, notes, and snippets.

@bl4de
bl4de / AngularUrlService.js
Last active September 24, 2018 09:13
AngularJS service for getting query string vars from url
app.service("UrlService", ["$location", function($location) {
// refernce to service for callbacks
var __service = this,
parts = {
"queryvars": {}
},
absUrl = $location.absUrl(),
// extract and parse url
elements = absUrl.split("?");
/**
* @ngDoc Directive
* @name app.Directive.onKeyEnter
* @module app
*
* @description
* this directive triggers callback function when enter key is pressed
*
* @author Mohan Singh <mslogicmaster@gmail.com>
*
const wordPlural = (word, amount) => {
word = word.toLowerCase()
if (amount === 1) {
return word
}
return pluralize(word)
}
const pluralize = word => {