diff --git a/src/params/paramTypes.ts b/src/params/paramTypes.ts index dec1e26c9..c65e7e4f4 100644 --- a/src/params/paramTypes.ts +++ b/src/params/paramTypes.ts @@ -23,7 +23,7 @@ export class ParamTypes { decode: valFromString, is: is(String), pattern: /.*/, - equals: val(true) + equals: (a, b) => a == b // allow coersion for null/undefined/"" }, "string": { encode: valToString, diff --git a/src/state/stateRegistry.ts b/src/state/stateRegistry.ts index c28a615b8..06daf8512 100644 --- a/src/state/stateRegistry.ts +++ b/src/state/stateRegistry.ts @@ -27,7 +27,7 @@ export class StateRegistry { url: '^', views: null, params: { - '#': { value: null, type: 'hash' } + '#': { value: null, type: 'hash', dynamic: true } }, abstract: true }; diff --git a/test/ng1/stateSpec.js b/test/ng1/stateSpec.js index 305842faa..8cbd87aa5 100644 --- a/test/ng1/stateSpec.js +++ b/test/ng1/stateSpec.js @@ -663,6 +663,21 @@ describe('state', function () { expect($location.hash()).toBe('frag'); })); + it('runs a transition when the location #fragment is updated', inject(function ($state, $q, $location, $transitions) { + var transitionCount = 0; + $transitions.onSuccess({}, function() { transitionCount++; }); + + $state.transitionTo('home.item', {id: 'world', '#': 'frag'}); + $q.flush(); + expect($location.hash()).toBe('frag'); + expect(transitionCount).toBe(1); + + $state.transitionTo('home.item', {id: 'world', '#': 'blarg'}); + $q.flush(); + expect($location.hash()).toBe('blarg'); + expect(transitionCount).toBe(2); + })); + it('injects $transition$ into resolves', inject(function ($state, $q) { $state.transitionTo('home'); $q.flush(); $state.transitionTo('about'); $q.flush();