I'm trying to sort fields dynamically by Ionic and AngularJs. I started by using the Modal Select plugin with the button like this:
<button class="button button-stable button-block icon-left ion-android-restaurant" modal-select="" ng-model="someModel" options="selectableNames" option-property="role" modal-title="Ordenar por..." header-footer-class="bar-assertive">Ordenar
<div class="option">
<h2>{{option.name}}</h2>
</div>
</button>
And the controller
like this:
// ORDENA POR...
$scope.selectableNames = [
{
name: "Por preço: Do Menor para o Maior",
role: "+cadastra_oferta_valor_com_desconto"
},
{
name: "Por preço: Do Maior para o Menor",
role: "-cadastra_oferta_valor_com_desconto"
},
{
name: "Por Maior Desconto (%)",
role: "-cadastra_oferta_desconto"
},
{
name: "Menor Prazo de Entrega",
role: "+fornecedor_configura_frete_prazo_entrega_min"
},
{
name: "Oferta em Ordem Alfabética",
role: "+cadastra_oferta_titulo_promocao"
},
//...
];
Putting my filter
into view this way:
<div class="card" ng-repeat="item in ofertass | filter:q | orderBy:someModel | unique: 'cadastra_oferta_cod_oferta'" ng-init="$last ? fireEvent() : null" href="#/nhaac/ofertas_singles/{{item.cadastra_oferta_cod_oferta}}">
Sort up, but the price fields that are:
{
name: "Por preço: Do Menor para o Maior",
role: "+cadastra_oferta_valor_com_desconto"
},
{
name: "Por preço: Do Maior para o Menor",
role: "-cadastra_oferta_valor_com_desconto"
},
// ...
How much is penny, he does not order right. What is curious, since the "discount" field that has the same format as the values fields it sorts well.
{
name: "Por Maior Desconto (%)",
role: "-cadastra_oferta_desconto"
},
I have tried to put | currency
on "role" but it does not accept. So I want to do this sort of order differently, but I do not know how and I did not find anything on the Internet. It would have to be a modal to filter these fields. My JSON
can be accessed here .
How can I create a sort order with several fields and types using "Modal" and this my JSON
. You do not necessarily need to use this plugin mentioned at the beginning of this question.
Thank you in advance.