parametrizedLocation

Extend angular.$location with support for a parametrized URL template with parameters (like angular.$resource) prefixed by `:`.


Keywords
angular, $location, $resource, parametrized, params, url, path, hash
License
MIT
Install
bower install parametrizedLocation

Documentation

#parametrizedLocation

Extend angular.$location with support for a parametrized URL template with parameters (like angular.$resource) prefixed by :. And added a filter paramsUrl.

$resource documentation: http://docs.angularjs.org/api/ngResource.$resource $location documentation: http://docs.angularjs.org/api/ng.$location

##Install Install with bower.

bower install --save parametrizedLocation

How to use

angular.module('moduleName', ['parametrizedLocation']);

##Methods $location.url

$location.url('/url/:id', {id:123, test:'test'});
//return $location, browser jumps to '/url/123?test=test'

$location.path

$location.path('/url/:id', {id:123, test:'test'});
//return $location, browser jumps to '/url/123'

$location.hash

$location.hash(':foo', {foo:'bar'});
//return $location, browser jumps to '#bar'

##Filters paramsUrl

$filter('paramsUrl')('/url/:id', {id:123, test:'test'});
//return /url/123?test=test

Or

<a href="{url | paramsUrl:params}">…</a>
<!-- <a href="/url/123?test=test">…</a> -->

##Todo

  • more tests (Statements: 88.16% (67 / 76), Branches: 71.11% (32 / 45), Functions: 82.35% (14 / 17), Lines: 88.16% (67 / 76))

##Thanks