mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-24 18:30:23 +00:00
Routes like '/bar/foovalue/barvalue' matching '/bar/:foo/:bar'
now are well mapped in $routeParams to:
{bar:'barvalue', foo:'foovalue'}
Closes: #1501
Signed-off-by: Gonzalo Ruiz de Villa <gonzaloruizdevilla@gmail.com>
32 lines
1,010 B
JavaScript
32 lines
1,010 B
JavaScript
'use strict';
|
|
|
|
describe('$routeParams', function() {
|
|
it('should publish the params into a service', function() {
|
|
module(function($routeProvider) {
|
|
$routeProvider.when('/foo', {});
|
|
$routeProvider.when('/bar/:barId', {});
|
|
});
|
|
|
|
inject(function($rootScope, $route, $location, $routeParams) {
|
|
$location.path('/foo').search('a=b');
|
|
$rootScope.$digest();
|
|
expect($routeParams).toEqual({a:'b'});
|
|
|
|
$location.path('/bar/123').search('x=abc');
|
|
$rootScope.$digest();
|
|
expect($routeParams).toEqual({barId:'123', x:'abc'});
|
|
});
|
|
});
|
|
|
|
it('should correctly extract the params when a param name is part of the route', function() {
|
|
module(function($routeProvider) {
|
|
$routeProvider.when('/bar/:foo/:bar', {});
|
|
});
|
|
|
|
inject(function($rootScope, $route, $location, $routeParams) {
|
|
$location.path('/bar/foovalue/barvalue');
|
|
$rootScope.$digest();
|
|
expect($routeParams).toEqual({bar:'barvalue', foo:'foovalue'});
|
|
});
|
|
});
|
|
});
|