如何使用角度过滤器过滤JSON?

时间:2020-02-06 19:37:07

标签: angularjs filter

我需要从我的一篇文章中获取信息,但是我建议的过滤器没有到达该标签,基本上是通过信息来过滤每个信息

HTML

<div bindonce ng-if="catalogoIndicesV3" class="row fila-pareja" id="panelindice"
     ng-repeat="indice in catalogoIndicesV3 | 
                filter:{indice.indice.slug:'internacional'}">
    <div class="panel panel-default">
        <div class="panel-body">
        {{indice.indice.nombre}}
        </div>
    </div>
</div>

控制器

angular.module('indicesApp')
.controller('MainCtrl', ['$scope', 'apiIMCO', 'apiimcov3', 'utils2', '$location', 'apiService',
    function($scope, apiIMCO, apiimcov3, utils, $location, apiService) {
        //,indice-de-informacion-del-ejercicio-del-gasto

        $scope.isFileType = function (string, extension){
          return (new RegExp(extension+"$", "i")).test(string);
        };

        $scope.shortifyString = function (string){
          return string.replace(/\s\W.*?$/, "");
        };

        apiService.getResource('/publicaciones?exclude_index=semaforo-del-sla')
          .then(function(response) {
            //console.log(response);

            response.forEach(function (entry){
                if(entry.url === null && 
                  ( (typeof entry['introduccion'] !== "undefined" &&
                     entry['introduccion'].length>0) ||
                    (typeof entry['vistas'] !== 'undefined' && 
                     entry['vistas'].length>0)
                  )
                ){                      
                    if(entry.categoria === "Informe Legislativo")
                    {
                      entry.url = 'http://imco.org.mx/finanzaspublicas/#!/informe-legislativo';
                    }
                    else {
                      entry.url = entry.slug + '/' ;   
                    }                        
                }
            });;
            $scope.catalogoIndicesV3 = response;
        });

        $scope.buscaO = utils.buscaEnArregloObjetos;
    }
]);

JSON

https://api.imco.org.mx/release/latest/publicaciones?exclude_index=semaforo-del-sla

0 个答案:

没有答案