I have the following structure:
array(
array('id' => 1, 'name' => 'aaa', 'thumbnailUrl' => 'some1'),
array('id' => 2, 'name' => 'ccc', 'thumbnailUrl' => 'some2'),
array('id' => 3, 'name' => 'bbb', 'thumbnailUrl' => 'some3')
)
And I display it like this:
<div ng-controller="CreationController">
<input type="radio" name="sortBy" id="id" ng-click="reverse=false;order('id',reverse)"><label for="id">id</label>
<input type="radio" name="sortBy" id="name" ng-click="reverse=false;order('name',reverse)"><label for="name">name</label>
<div class="creations accordion" ng-repeat="creation in creations">
<h3>
{if !empty("[[creation.thumbnailUrl]]")}
<img src="[[creation.thumbnailUrl]]" class="creation-thumb-header">
{else}
<img src="/image/placeholder.png" class="creation-thumb-header">
{/if}
#[[creation.id]] [[creation.name]]
</h3>
<div class="row">
[[creation.name]]
</div>
</div>
</div>
I use smarty to do that, along with angular ([[ and ]] tags). The problem is that the array is not being sorted. Clicking radio buttons changes nothing.
What's wrong, and how to do this?
exampleApp.controller('CreationController', ['$scope', '$filter', function($scope, $filter) {
var orderBy = $filter('orderBy');
$scope.creations = creations;
$scope.order = function(predicate, reverse) {
$scope.creations = orderBy($scope.creations, predicate, reverse);
};
$scope.order('id',true);
}]);
Also, is there a way to do this using select? Could you provide some example?