I am trying to sort the array using orderBy:names, but its not working , can some one tell me where i am doing the mistake??
<body data-ng-app="app" data-ng-controller="controller1" >
<div class="container">
<div class="row">
<input type="text" ng-model="searchbox" />
<li ng-repeat="name in names|filter:searchbox|orderBy:'names'">
{{name}}
</li>
</div>
</div>
<script type="text/javascript">
var app=angular.module('app', []).controller('controller1', ['$scope', function($scope){
$scope.names=['david', 'shreya', 'ankit'];
}]);
</script>
</body>
You can order by the toString() method. See: How to make orderby filter work on array of strings?. From that answer:
<ul ng-repeat="strVal in arrVal | orderBy:'toString()' | filter:searchText">