When the user click on 'sort by book title' button, I would like to change "ng-repeat="x in books' to ng-repeat="x in books|orderBy:'country'" in HTML.
How can I create that action in javascript/angular?
https://jsfiddle.net/dbxtcw9w/
<section id="App2" ng-app="form-input" ng-controller="ctrl">
<summary class="row book-component">
<div ng-repeat='x in books' class="col-md-12 col-sm-12 col-xs-12" >
<img class="thumbnail-image" >
<div>
<h2 ng-bind="x.title" class="title"></h2>
<h4 ng-bind="x.author" class="author" style="color:grey;"></h4>
<hr>
<h5>FREE SAMPLE <span class="review" onclick="review(this)">REVIEW</span></h5>
</div>
</div>
</summary>
<button style="margin-top:30px" class="btn-lg btn-success"
ng-click="sort()" onclick="sort()">Sort by book title</button>
</section>
<script>
var app2 = angular.module('form-input', []);
app2.controller('ctrl', function($scope) {
$scope.books=[
{title:'Jani',author:'Norway'},
{title:'Hege',author:'Sweden'}
];
})
</script>