I’m not able to delete the client index with Javascript (Angularjs)

Asked

Viewed 109 times

0

I have a table with several columns, formed through an array with several positions (on average 50 clients), need to delete the result according to the client’s condition, if the client is PENDING it exits the table (exits the array).

inserir a descrição da imagem aqui

img link: http://ap.imagensbrasil.org/images/2017/03/15/pendente-01.png

I am populating the table with NG-REPEAT using the Angularjs ex: {{ item.nome }}, I know that I must apply the rule in my main Controller so that the method (function) is visible in every application and can be reused.

Question: I need a rule (function) that disables or deletes all results that are like: PENDANT related to the client, as seen in the image, remembering that it is no use to delete only a precise variable delete the index related to the client that is PENDING.

I’m not able to delete the customer index.

anyone has a solution, can anyone help me? thanks!!

3 answers

0

You have 3 options,

  • Make a search in the bank already deleting the pending items.
  • Run foreach by creating another list and deleting pending items from the new list
  • insert in the div of the ng-repeat item the attribute ng-if="item.document !== " Sending Pendant"

0

So, I am beginner in Angularjs, the table result is generated when I use a function to detail the clients, this function uses a response (array) within a FOR (generates a loop with the client list), so I use this answer to popular the table through the date-ng-repeat, so far the table returns all customers need to restrict the pending shipping clients...

the problem is: I can’t access the database only the variable that comes through an array, I tried to deal with direct ng-if in the table but it ends up disappearing with the column (I don’t know if I applied in the correct location), I believe that one of the ways to do this treatment would be when I call the function p/ filter customers, I confess that I am not able to do this...

applied ng-if to DIV crashed rederization, seeing the error in the console (firebug) (Error: [$parse:ueoe] Unexpected end of Expression: item.stateAtualClient !==)

I believe that I have to apply when I call the function that details the customers, within the function that details the customers I have two FOR, each one makes a treatment at the end I have an array with the total list of customers, that part that I can not see how it would look... would it work to create a third treatment within that loop??

(I think... ) a good practice would be to do this treatment outside of FOR to facilitate maintenance, I tried to do so but could not finish...

self.filtrarSituacao = function(estadoAtualCliente){
        return self.filtroSituacaoCliente.filter (function filtrar                      (estadoAtualCliente){
        return filtroSituacaoCliente !== ('Pendente de Envio');
        });

ps: it took me a while to answer why I was testing the possibilities here, I will give a better read on foreach

0

Have you tried using the ng-if (can also be used ng-show or ng-Hide)?

Your links are blocked for me, so I’ll show you an example.

E.g.:

var app = angular.module('app', []);

app.controller('ctrl', function($scope){
    $scope.records = [
        {
            "nome" : "Alfreds Futterkiste",
            "pais" : "Alemanha"
        },{
            "nome" : "Berglunds snabbköp",
            "pais" : "Suecia"
        },{
            "nome" : "Centro comercial Moctezuma",
            "pais" : "Mexico"
        },{
            "nome" : "Ernst Handel",
            "pais" : "Austria"
        }
    ]
});

<div ng-app="app" ng-controller="ctrl">
    <div ng-repeat="valor in records">
        <div ng-if="valor.pais !== 'Austria'">{{valor.nome}}</div>
    </div>
</div>

FIDDLE

Browser other questions tagged

You are not signed in. Login or sign up in order to post.