Skip to content

Commit 016ff92

Browse files
philBrownchristopherthielen
authored andcommitted
cherry-pick 71d7469 from 0.2.17
1 parent a046f56 commit 016ff92

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/ng1/stateFilters.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
*/
1313
$IsStateFilter.$inject = ['$state'];
1414
export function $IsStateFilter($state) {
15-
return function(state) {
16-
return $state.is(state);
15+
return function(state, params, options) {
16+
return $state.is(state, params, options);
1717
};
1818
}
1919

test/stateFiltersSpec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ describe('isState filter', function() {
66
beforeEach(module(function($stateProvider) {
77
$stateProvider
88
.state('a', { url: '/' })
9-
.state('a.b', { url: '/b' });
9+
.state('a.b', { url: '/b' })
10+
.state('with-param', { url: '/with/:param' });
1011
}));
1112

1213
it('should return true if the current state exactly matches the input state', inject(function($parse, $state, $q, $rootScope) {
@@ -20,6 +21,18 @@ describe('isState filter', function() {
2021
$q.flush();
2122
expect($parse('"a" | isState')($rootScope)).toBe(false);
2223
}));
24+
25+
it('should return true if the current state and param matches the input state', inject(function($parse, $state, $q, $rootScope) {
26+
$state.go('with-param', {param: 'a'});
27+
$q.flush();
28+
expect($parse('"with-param" | isState: {param: "a"}')($rootScope)).toBe(true);
29+
}));
30+
31+
it('should return false if the current state and param does not match the input state', inject(function($parse, $state, $q, $rootScope) {
32+
$state.go('with-param', {param: 'b'});
33+
$q.flush();
34+
expect($parse('"with-param" | isState: {param: "a"}')($rootScope)).toBe(false);
35+
}));
2336
});
2437

2538
describe('includedByState filter', function() {

0 commit comments

Comments
 (0)