ngOptions
and ngRepeat
both provide support for iterating over collections and objects, which is crucial for handling your data. The values of DynamicProductName
are essentially just keys within the products
object.
The basic syntax for implementing ngOptions
in this scenario is:
<select ng-model="test" ng-options="key as value for (key , value) in data"></select>
In this instance, the value stored in your model would be key
, while value
would be displayed in the select element.
Since your value is slightly more nested, it would be: value.attributes.location
.
If you prefer to have the value instead (which may be more relevant data), you can modify the code to:
<select
data-ng-model="test"
data-ng-options="value as value.attributes.location for (key , value) in todos.products"
>
</select>