Skip to content

URL array param with default empty value is left undefined #2222

Closed
@AdamSelene

Description

@AdamSelene

I'm having an issue with an array state parameter with a default empty value:

  • when the param is not declared in the URL pattern (param4 in the jsbin below), the default value is indeed []
  • when the param is declared in the URL pattern (param3 and param5) AND when it's absent from the URL (allowed since it's supposed to be optional), then it's initialized to 'undefined' (even worse than being undefined: the parameter is present in the params object but has an undefined value, which prevents me from easily using angular.extend or angular.merge, for instance)

See https://jsbin.com/bebeheciju/edit?html,console,output for example

The problem comes from the arrayUnwrap function in the Type definition, which specifically returns 'undefined' for empty arrays.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions