see the fiddle here http://jsfiddle.net/prantikv/gcz4gwgw/1/
i want to get one i item on the top of the list and the rest in alphabetical order:
<div ng-controller="MyCtrl">
<ul>
<li ng-repeat="value in name | orderBy:'name'">{{value.name}} </li>
</ul>
</div>
In my controller i have the following
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.name=[
{name:'zani',country:'Norway'},
{name:'aege',country:'Sweden'},
{name:'Kai',country:'Denmark'}]
}
what i want is the name "kai" to come first and then the rest in alphabetical order.
================Edit===============
now i have played and got the following
in my view:
<div ng-controller="MyCtrl">
<ul>
<li ng-repeat="value in name | orderBy:myValueFunction ">{{value.name}} </li>
</ul>
</div>
in my controller :
$scope.myValueFunction = function(value) {
if(value.name == "kai"){
return value.name;
}else{
//what todo here so the rest of the list is sorted alphabetically
}
}