I am attempting to link an unspecified array index based on a certain property in angularjs.
<select id="iditemtype" ng-model="bindSpecificAttribute(entity, e)"
ng-options="e as e.configValue for e in allConfig() | filter:{typeName:'ItemType'}">
</select>
//javascript method inside controller
function bindSpecificAttribute()
{
var dataIndex = -1;
for(var i=0;i<entity.attributes.length;i++){
if(entity.attributes[i].type=='ItemType'){
dataIndex = i;
break;
}
}
if(dataIndex==-1){
entity.attributes.push(0, e);
}
else
entity.attributes[dataIndex] = e;
}
The excerpt above reflects my desired outcome. I aim to connect a specific attribute from a dropdown list.
I am utilizing angularjs 1.3