Files
side-by-side/source/scripts/services/route.js.coffee
T
2014-12-18 22:27:01 +01:00

23 lines
541 B
CoffeeScript

angular.module("sideBySide").service "route", ['$location', ($location) ->
@params = $location.path()
.split('/')
.filter((item) -> item)
.map (item) ->
item.split(':')
.reduce((params, param) ->
params[param[0]] = param[1]
params
, {})
@params.base = '' if 'base' not of @params
@appUrl = $location.absUrl()
.substring(0, $location.absUrl().length - $location.url().length)
@update = (key, value) ->
@params[key] = value
$location.path (property + ':' + value for property, value of @params).join('/')
@
]