Skip to content

Commit 0da45a1

Browse files
committed
refactor($state): simplify include()
1 parent 34207b1 commit 0da45a1

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/state.js

+4-13
Original file line numberDiff line numberDiff line change
@@ -1043,29 +1043,20 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
10431043

10441044
$state.includes = function includes(stateOrName, params) {
10451045
if (isString(stateOrName) && isGlob(stateOrName)) {
1046-
if (doesStateMatchGlob(stateOrName)) {
1047-
stateOrName = $state.$current.name;
1048-
} else {
1046+
if (!doesStateMatchGlob(stateOrName)) {
10491047
return false;
10501048
}
1049+
stateOrName = $state.$current.name;
10511050
}
1052-
10531051
var state = findState(stateOrName);
1052+
10541053
if (!isDefined(state)) {
10551054
return undefined;
10561055
}
1057-
10581056
if (!isDefined($state.$current.includes[state.name])) {
10591057
return false;
10601058
}
1061-
1062-
var validParams = true;
1063-
angular.forEach(params, function(value, key) {
1064-
if (!isDefined($stateParams[key]) || $stateParams[key] !== value) {
1065-
validParams = false;
1066-
}
1067-
});
1068-
return validParams;
1059+
return equalForKeys(params, $stateParams);
10691060
};
10701061

10711062

0 commit comments

Comments
 (0)