繁体   English   中英

ng-repeat中项目的长度角度

[英]Length angular of items in ng-repeat

首先,我有这张桌子:

在此处输入图片说明

在哪里可以看到estado栏中的不同颜色。 有4种不同的情况。 我想计算一下这种不同的情况。 例如,在这种情况下,有:有效(绿色):1,沃达丰(绿色+徽标):1,无效(红色):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>

和控制器:

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...');
            });




});

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

您几乎正确吗? 我曾在您的example中使用plunker ,但马上就成功了吗?

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

似乎为我工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM