diff --git a/src/stateFilters.js b/src/stateFilters.js index e0a117580..9156e6f42 100644 --- a/src/stateFilters.js +++ b/src/stateFilters.js @@ -9,8 +9,8 @@ */ $IsStateFilter.$inject = ['$state']; function $IsStateFilter($state) { - var isFilter = function (state) { - return $state.is(state); + var isFilter = function (state, params) { + return $state.is(state, params); }; isFilter.$stateful = true; return isFilter; diff --git a/test/stateFiltersSpec.js b/test/stateFiltersSpec.js index 7f2eb9beb..a3aa93f06 100644 --- a/test/stateFiltersSpec.js +++ b/test/stateFiltersSpec.js @@ -3,7 +3,8 @@ describe('isState filter', function() { beforeEach(module(function($stateProvider) { $stateProvider .state('a', { url: '/' }) - .state('a.b', { url: '/b' }); + .state('a.b', { url: '/b' }) + .state('with-param', { url: '/with/:param' }); })); it('should return true if the current state exactly matches the input state', inject(function($parse, $state, $q, $rootScope) { @@ -17,6 +18,18 @@ describe('isState filter', function() { $q.flush(); expect($parse('"a" | isState')($rootScope)).toBe(false); })); + + it('should return true if the current state and param matches the input state', inject(function($parse, $state, $q, $rootScope) { + $state.go('with-param', {param: 'a'}); + $q.flush(); + expect($parse('"with-param" | isState: {param: "a"}')($rootScope)).toBe(true); + })); + + it('should return false if the current state and param does not match the input state', inject(function($parse, $state, $q, $rootScope) { + $state.go('with-param', {param: 'b'}); + $q.flush(); + expect($parse('"with-param" | isState: {param: "a"}')($rootScope)).toBe(false); + })); }); describe('includedByState filter', function() {