When the user clicks on the 'sort by book title' button, I want to change the ng-repeat="x in books' to ng-repeat="x in books|orderBy:'country'" in the HTML code.
How can I achieve this action using JavaScript/Angular?
<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>