Skip to content

Commit 2199889

Browse files
committed
Merge pull request #1736 from cyrilf/includedByState-improvement
feat($IncludedByStateFilter): add parameters to $IncludedByStateFilter
2 parents cbf7547 + 963f6e7 commit 2199889

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/stateFilters.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ function $IsStateFilter($state) {
2727
*/
2828
$IncludedByStateFilter.$inject = ['$state'];
2929
function $IncludedByStateFilter($state) {
30-
var includesFilter = function (state) {
31-
return $state.includes(state);
30+
var includesFilter = function (state, params, options) {
31+
return $state.includes(state, params, options);
3232
};
3333
includesFilter.$stateful = true;
3434
return includesFilter;

test/stateFiltersSpec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ describe('includedByState filter', function() {
3838
$stateProvider
3939
.state('a', { url: '/' })
4040
.state('a.b', { url: '/b' })
41-
.state('c', { url: '/c' });
41+
.state('c', { url: '/c' })
42+
.state('d', { url: '/d/:id' });
4243
}));
4344

4445
it('should return true if the current state exactly matches the input state', inject(function($parse, $state, $q, $rootScope) {
@@ -58,4 +59,16 @@ describe('includedByState filter', function() {
5859
$q.flush();
5960
expect($parse('"a" | includedByState')($rootScope)).toBe(false);
6061
}));
62+
63+
it('should return true if the current state include input state and params', inject(function($parse, $state, $q, $rootScope) {
64+
$state.go('d', { id: 123 });
65+
$q.flush();
66+
expect($parse('"d" | includedByState:{ id: 123 }')($rootScope)).toBe(true);
67+
}));
68+
69+
it('should return false if the current state does not include input state and params', inject(function($parse, $state, $q, $rootScope) {
70+
$state.go('d', { id: 2377 });
71+
$q.flush();
72+
expect($parse('"d" | includedByState:{ id: 123 }')($rootScope)).toBe(false);
73+
}));
6174
});

0 commit comments

Comments
 (0)