ng-repeat中项目的长度角度

时间:2022-08-23 23:40:25

First, I have this table:

首先,我有这个表:

ng-repeat中项目的长度角度

Where you can see, different colours in the column estado. There are 4 different cases. And i Want to count this different cases. For example in this case there are: Active(green): 1, Vodafone(green+logo): 1, Desactive(Red): 1, Pending(orange):1. But it can change depend of the case.

你可以在哪里看到,estado列中的颜色不同。有4种不同的情况。我想要计算这种不同的情况。例如,在这种情况下有:Active(绿色):1,Vodafone(绿色+徽标):1,Desactive(红色):1,待定(橙色):1。但它可以根据具体情况而改变。

<div class="input-group">
                      <div>  <h>Instalaciones: {{filteredsites.length}}</h>  <h>Active: {{}}</h> <h>Vodafone: {{}}</h> <h>Desactive: {{}}</h> <h>Pending: {{}}</h></div>

                </div>
<div class="panel-body">
                <div class="row">
                    <div class="col-lg-3">
                        <div >
                            <table class="table table-bordered table-hover table-responsive table-striped dataTable no-footer" data-sort-name="name" data-sort-order="desc">
                                <tr role = "row" class="info text-center">
                                    <th ng-click="order('msisdn')">Número Teléfono</th>
                                    <th ng-click="order('icc')">ICC</th>

                                    <!--th>IMEI</th-->
                                    <th ng-click="order('ActivationStatus')">Estado</th>
                                    <th ng-click="order('sitename')">Instalación</th>
                                    <th ng-click="order('siteaddress')">Dirección</th>
                                    <th ng-click="order('sitecity')">Ciudad</th>
                                    <th ng-click="order('sitezip')">Código Postal</th>

                                    <th ng-click="order('phonedesc')">Modelo Teléfono</th>



                                </tr>


                                <tr class=" text-center" ng-repeat-start="object in filteredsites = (objects | filter:searchText | filter:{parentgroupid:selectedgroup||undefined}) | filter:tableFilter| orderBy:predicate:reverse" ng-click="showDetails = ! showDetails" >
                                    <td>{{object.msisdn}}</td>
                                    <td>{{object.icc}}</td>

                                    <!--td>{{object.ActivationStatus}}</td-->
                                    <td><span ng-init="getStatusCount(object.ActivationStatus)"  ng-show="object.ActivationStatus=='AC' && object.ContractingMode=='0'" class="fa fa-square fa-3x"style="color:lime"></span><span ng-show="object.ContractingMode=='2' && object.ActivationStatus=='AC'  "  ><img src="../img/Vodafone_logo.png" width="40" height="40" style="background-color: lime"></span><span ng-show="object.ActivationStatus=='PA'"  class="fa fa-square fa-3x"style="color:yellow"></span><span ng-show="object.ActivationStatus=='DE'" class="fa fa-square fa-3x"style="color:red"></span></td>
                                    <td>{{object.sitename}}</td>
                                    <td>{{object.siteaddress}}</td>
                                    <td>{{object.sitecity}}</td>
                                    <td>{{object.sitezip}}</td>
                                    <td><span ng-show="object.phonedesc==''"></span><span ng-show="object.phonedesc=='Desconocido'">Desconocido</span><span></span>{{getPhoneModel(object.phonedesc)}}</td>
                                </tr>

                           </table>
                        </div>
                        <!-- /.table-responsive -->




                    </div>
                    <!-- /.col-lg-4 (nested) -->

                    <!-- /.col-lg-8 (nested) -->
                </div>

And the controller:

和控制器:

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

app.controller('dashboardController', function ($scope, $http, $modal) {
    $scope.objects = [];
    $scope.grupos = [];
    $scope.longitud = [];
    $scope.eventos = [];



    var URL = "/api/auth/logout";
    var URLOperation = "/api/sites";
    var URLModel = "http://localhost:81/api/phonelist/";
$scope.getStatusCount= function (status){
   // console.log(status);

    var active = 0;
    active++;
    console.log(active);
    angular.forEach(status ,function(obj) {
        if (obj.status == status) {
            console.log(obj.status);
            console.log(status);
            console.log(active);
            active++;
            console.log(active);
        } });


}


//Funci?n que devuelve las instalaciones de un usuario
    $http.get(URLOperation, $scope)
            .success(function (data) {
                var groups = data;
                angular.forEach(groups, function (group) {
                    var group2 = group;
                    angular.forEach(group2.sites, function (group3) {
                        $scope.longitud.push(group3);
                        $scope.objects.push(group3);
                        $scope.predicate = 'msisdn';
                        $scope.reverse = true;
                        $scope.order = function (predicate) {
                            $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false;
                            $scope.predicate = predicate;
                        };
                    })
                });
            })
            .error(function (data) {
                window.alert('Something Wrong...');
            });




});

If someone can help me the count the different ActivationStatus cases i will appreciated.

如果有人可以帮我计算不同的ActivationStatus案例,我将不胜感激。

1 个解决方案

#1


1  

You pretty much had it correct? I worked on your example in plunker and it worked right off the bet?

你几乎是正确的吗?我在plunker中研究了你的例子,它在赌注下工作了吗?

ng-show="object.ActivationStatus=='AC' && object.ContractingMode=='0'"

Seemed to be working for me.

似乎是为我工作。

#1


1  

You pretty much had it correct? I worked on your example in plunker and it worked right off the bet?

你几乎是正确的吗?我在plunker中研究了你的例子,它在赌注下工作了吗?

ng-show="object.ActivationStatus=='AC' && object.ContractingMode=='0'"

Seemed to be working for me.

似乎是为我工作。