Skip to content

TypeError : cannot read property "type" of undefined (+ fix) #3394

@Leogiciel

Description

@Leogiciel

This issue tracker is for Bug Reports and Feature Requests only.
Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.

This is a:

  • [X ] Bug Report
  • Feature Request
  • General Query

My version of UI-Router is: 0.4.2

Bug Report

Current Behavior:

angular.js:14328 TypeError: Cannot read property 'type' of undefined at http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:3517:44 at Array.reduce (native) at Object.is (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:3515:44) at exactMatch (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:4632:58) at update (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:4621:15) at Scope.$broadcast (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular.js:18298:28) at http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular-ui-router.js:3427:22 at processQueue (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular.js:16648:37) at http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular.js:16692:27 at Scope.$eval (http://localhost/WMWEB/Accel.Workflow.Web.FormHost/Content/libs/angular.js:17972:28)

Expected Behavior:

No error in the console

Possible fix:

Actual code at line 3517 is:
return acc && !paramDef || paramDef.type.equals($stateParams[key], params[key]);
If "acc" is false and "paramDef" is undefined, due to operators priority "acc && !paramDef" is interpreted first and is false, so "paraDef.type.equals($stateParams[key], params[key]);" is interpreted, and logically throws an exception.

Fixed that this way:
return acc && (!paramDef || paramDef.type.equals($stateParams[key], params[key]));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions