javascript - AngularJs: The expression of the orderBy doesnt work to me -
i'm using angularjs 1.2.8. here's question:
i want order array of objects using filter, , strange thing happens me.
when use ng-repeat="thread in threads" without filter orders ascendant.
when use ng-repeat="thread in threads | orderby: '-':true" orders descendant.
here's problem: when use ng-repeat="thread in threads | orderby: '-':false" orders descendant anyway.
thank all.
are trying order list based on property? orderby used in relation property within each item in ng-repeat:
descending based on example property title
ng-repeat="thread in threads | orderby: '-title'"
ng-repeat="thread in threads | orderby: '-date'"
ng-repeat="thread in threads | orderby: '-id'"
ascending based on example property title
ng-repeat="thread in threads | orderby: '-title'"
ng-repeat="thread in threads | orderby: '+date'"
ng-repeat="thread in threads | orderby: '+id'"
angular documentation on orderby. notice '+' or '-' affixed beginning of property name within single quote characters.
you can use in combination custom filter named query, perhaps on text input element ng-model="query". example:
ng-repeat="thread in threads | filter:query | orderby: '-title'"
let me know if helps or clarify question identify properties of thread entity , property hoping sort on.
to order on index:
descending ng-repeat="thread in threads | orderby: thread.$index:true"
ascending ng-repeat="thread in threads | orderby: thread.$index:false"
jsfiddle:
Comments
Post a Comment