Skip to content

Instantly share code, notes, and snippets.

@lucassus
Forked from wvuong/angular.jsp
Created May 30, 2014 13:54
Show Gist options
  • Save lucassus/43defa162f71bf839443 to your computer and use it in GitHub Desktop.
Save lucassus/43defa162f71bf839443 to your computer and use it in GitHub Desktop.
<script>
// inject inlined constants
angular.module('app.constants', [])
.constant('contextPath', '${pageContext.request.contextPath}');
</script>
// create the filter that uses the context path constant
angular.module('app.filters', ['app.constants'])
.filter('relativeUrl', ['contextPath', function(contextPath) {
return function(url) {
return contextPath + url;
};
}]);
// inject the filter and use the context path
angular.module('app.services', ['ngResource']).
factory('PlaceService', ['$filter', '$resource', function($filter, $resource) {
var relativeUrl = $filter('relativeUrl');
return $resource(relativeUrl('/rest/places/:id'), {id: '@id'});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment