2
I’m trying to sort fields dynamically by Ionic and Angularjs. I started using the plugin Modal Select, 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
thus:
// 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
in view in 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}}">
It orders up well, 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 has penny, it does not order right. What is curious, because the field "discount" that has the same format as the values fields it orders well.
{
name: "Por Maior Desconto (%)",
role: "-cadastra_oferta_desconto"
},
I’ve tried to put | currency
in the "role" but does not accept. So I want to do this ordering differently, but I do not know how and I found nothing on the Internet. It would have to be a modal to filter these fields. Mine JSON
can be accessed here.
How can I create a sort with several fields and types using "Modal" and this mine JSON
. Not necessarily needing to use this plugin mentioned at the beginning of this issue.
Thanks in advance.
Can you provide a Codepen with your code? Here is a model of the Modal Select to use: http://codepen.io/bianchimro/pen/epYQO?editors=101
– pharoeste