When utilizing ui-router to retrieve parameter values from a URL using $stateParam
, one of the parameters is an ID number that may or may not start with 00
. For example, 0034323343
. Throughout the entire application, the leading zeros remain intact. However, there seems to be an issue when adding state to an object like this:
SharedDataService.setBreadcrumb({
state: 'notes({ claimID: ' + $stateParams.claimID + ', cardholderId: ' + $stateParams.cardholderId + ' })',
name: 'Notes'
});
For some reason, the leading zero gets stripped off. The ID ends up being 34323343
in the URL. Despite confirming that
typeof($stateParams.cardholderId)
returns string
, the zero goes missing. Why could this be happening?
Below is the object that gets saved:
Object {state: "notes({ claimID: 187337, cardholderId: 0034323343 })", name: "Notes"}
I printed this object to console upon setting this value. Notice how the state shows the cardholderId
in the correct format - with leading zeros. Yet, why does it change to an integer when displayed inside a div using {{ crumb.state }}
?