Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$parse().assign() for expression with numeric index creates object instead of array #9820

@zgmnkv

Description

@zgmnkv

http://jsfiddle.net/bdwpnr5c/1/

<input ng-model="model[0]"/>
<pre>{{ model | json }}</pre>

gives

{
  "0": "value"
}

but expected result is

[
  "value"
]

Expected result could be achieved with manual assigning array value to model

<div ng-init="model = []"></div>
<input ng-model="model[0]"/>
<pre>{{ model | json }}</pre>

but it's not always easy to handle for complex objects (like model[0].prop.arrayProp[1].innerProp)

It should be easy to check if key is numeric and create array instead of object in this case.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions