57
rated 0 times
[
62]
[
5]
/ answers: 1 / hits: 13966
/ 10 Years ago, mon, june 30, 2014, 12:00:00
i have to display the JSON data in drop down list ,for that i have two options one of the options is By using ng-repeat and other one is ng-options.
ng-repeat code :
in html file :
<select>
<option ng-repeat=prod in testAccounts value={{prod.id}}>{{prod.name}}</option>
</select>
and in script file:
$http.get('document.json').success(function (data)
{
$scope.testAccounts = angular.fromJson(data);
}
and other one ng-options :
in html file :
<select ng-model=selectedTestAccount ng-options=c as c.name for c in testAccounts1></select>
in script file:
$http.get('document.json').success(function (data)
{
$scope.testAccounts1 = data;
$scope.selectedTestAccount = $scope.testAccounts1[0];
}
Now i want to know which one is best for my project to improve the performance .Any guidelines please .
More From » json