Abstract route service

This commit is contained in:
Vit Brunner
2014-11-11 19:19:35 +01:00
parent 6c4a600270
commit 3ebdaac320
3 changed files with 26 additions and 27 deletions
+17
View File
@@ -0,0 +1,17 @@
angular.module("sideBySide").service "route", ['$location', ($location) ->
@params = $location.url()
.split('/')
.filter((item) -> item)
.map (item) ->
item.split(':')
.reduce((params, param) ->
params[param[0]] = param[1]
params
, {})
@params.base = '' if 'base' not of @params
@params.base = @params.base.replace(/\./g, '/')
@appUrl = $location.absUrl()
.substring(0, $location.absUrl().length - $location.url().length)
]