I've developed a reusable directive similar to a dropdown, but this dropdown opens in a modal and is functioning well.
The structure of my directive is as follows:
<p-select items="deptStations" header-text="Select " text="Select departure..." text-icon="ion-chatbubble-working" text-field="City_Name_EN" text-field2="City_Code" value-field="City_Code" ng-model="deptStation.value">
</p-select>
<p-select items="arrStations" header-text="Select " text="Select arrival..." text-icon="ion-chatbubble-working" text-field="D.City_Name_EN" text-field2="D.City_Code" value-field="D.City_Code" ng-model="arrStation.value">
</p-select>
This is the HTML structure of my directive:
<ion-content>
<div class="list">
<label ng-repeat="item in items | filter:search" class="item item-text-wrap" ng-click='validateSingle(item)'>
{{item[textField]}} {{textField2 !== '' ? " (" + item[textField2] + ")" : ""}}
</label>
</div>
</ion-content>
However, I'm facing an issue when dealing with JSON data that has nested levels. For example:
[{City_Name_EN:'Abu Dhabi', City_Code:'AUH' },
{City_Name_EN:'Alexandria',City_Code:'HBE' }]
In cases where there are 2 levels of nested JSON, like below, it does not work properly:
[{D:{City_Code:'AMM',City_Name_EN:'Amman'},
D:{City_Code:'BKK',City_Name_EN:'Bangkok'}}]
So, I am looking for a way to dynamically handle this part: {{item[textField]}}
You can view my plunkr here: http://plnkr.co/edit/GxM78QRwSjTrsX1SCxF7?p=preview