I can not delete the customer index with JavaScript (AngularJS)

0

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

imglink: link

I'm populating the table with NG-REPEAT using the angularjs eg: {{item.name}}, I know I should apply the rule on 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: PENDING referring to the client, as seen in the img, remembering that it is not enough to delete only one precise variable to delete the customer-related index found as PENDING.

I can not delete the customer index.

Someone has a solution, can anyone help me? thank you!!

    
asked by anonymous 14.03.2017 / 18:41

3 answers

0

You have 3 options,

  • Search the database by already deleting the pending items.
  • Run the foreach by creating another list and deleting the pending items from the new list
  • insert the ng-repeat item's div into the div of the ng-repeat item: ng-if="item.document! ==" Shipping Pending "
14.03.2017 / 19:07
0

So, I'm a beginner in angularjs, the result of the table is generated when I use a function to detail the clients, this function uses a response (array) inside a FOR (it generates a loop with the list of clients), hence this response to popular table through the data-ng-repeat, so far the table returns all clients need to restrict pending shipping clients ...

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

Apply ng-if in DIV screwed the rederization, to see the error in the console (firebug) (Error: [$ parse: ueoe] Unexpected end of expression: item.stado CurrentClient! ==)

I believe that I have to apply when I call the function that details the clients, within the function that details the clients I have two FOR, each one makes a treatment in the end I have an array with the total list of clients, that part that does not to getting a preview of how it would look ... would it be okay 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 this but I could not finish ...

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

ps: I've been waiting for the answer because I was testing the possibilities here, I'd better read the foreach

    
14.03.2017 / 20:48
0

Have you tried using 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

    
15.03.2017 / 20:28