Skip to content

Commit b1a5155

Browse files
fix(StateService): Compare typed parameters in .is() and .includes()
Closes angular-ui/ui-router#3154
1 parent d49ca1d commit b1a5155

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/state/stateService.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,10 @@ export class StateService {
410410
let state = this.router.stateRegistry.matcher.find(stateOrName, options.relative);
411411
if (!isDefined(state)) return undefined;
412412
if (this.$current !== state) return false;
413-
return isDefined(params) && params !== null ? Param.equals(state.parameters(), this.params, params) : true;
413+
if (!params) return true;
414+
415+
let schema: Param[] = state.parameters({ inherit: true }).filter(param => params.hasOwnProperty(param.id));
416+
return Param.equals(schema, Param.values(schema, params), this.params);
414417
};
415418

416419
/**
@@ -463,8 +466,10 @@ export class StateService {
463466

464467
if (!isDefined(state)) return undefined;
465468
if (!isDefined(include[state.name])) return false;
466-
// @TODO Replace with Param.equals() ?
467-
return params ? equalForKeys(Param.values(state.parameters(), params), this.params, Object.keys(params)) : true;
469+
if (!params) return true;
470+
471+
let schema: Param[] = state.parameters({ inherit: true }).filter(param => params.hasOwnProperty(param.id));
472+
return Param.equals(schema, Param.values(schema, params), this.params);
468473
};
469474

470475

0 commit comments

Comments
 (0)