I am looking to display JSON data in a dropdown list, and I have two options to choose from. The first option is using ng-repeat, while the other option is ng-options.
Using ng-repeat:
In the HTML file:
<select>
<option ng-repeat="prod in testAccounts" value="{{prod.id}}">{{prod.name}}</option>
</select>
In the script file:
$http.get('document.json').success(function (data)
{
$scope.testAccounts = angular.fromJson(data);
}
The second option is ng-options:
In the HTML file:
<select ng-model="selectedTestAccount" ng-options="c as c.name for c in testAccounts1"></select>
In the script file:
$http.get('document.json').success(function (data)
{
$scope.testAccounts1 = data;
$scope.selectedTestAccount = $scope.testAccounts1[0];
}
Now I need to determine which method would be best for my project in terms of performance improvement. Any guidelines or suggestions are welcome.