Problem filtering arrangements in JS

0

I have the following scenario:

var myApp = angular.module('myApp',[]).controller("MyCtrl", MyCtrl);
function MyCtrl($scope) {
    $scope.telas = [{"ID":1,"Nombre":"Beige","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":3,"Nombre":"Ivory","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":4,"Nombre":"Negro","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":5,"Nombre":"Blanco 15 oz.","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":12,"Nombre":"BLACKOUT VINILICO ECO"}},{"ID":6,"Nombre":"Gris","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":12,"Nombre":"BLACKOUT VINILICO ECO"}},{"ID":7,"Nombre":"Natural","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":12,"Nombre":"BLACKOUT VINILICO ECO"}},{"ID":8,"Nombre":"Gris","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":9,"Nombre":"Blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":10,"Nombre":"Blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":12,"Nombre":"BLACKOUT VINILICO ECO"}},{"ID":15,"Nombre":"Uganda Tabaco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":2,"Nombre":"FIBRA VEGETAL"}},{"ID":16,"Nombre":"Blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":3,"Nombre":"5% POLIESTER"}},{"ID":17,"Nombre":"Blanco - Gris","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":3,"Nombre":"5% POLIESTER"}},{"ID":18,"Nombre":"Blanco - Beige","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":3,"Nombre":"5% POLIESTER"}},{"ID":19,"Nombre":"Bicolor 2958 natural","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":20,"Nombre":"Liso 2861 Blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":14,"Nombre":"ALGODÓN Y POLIÉSTER TRANSLÚCIDO"}},{"ID":23,"Nombre":"Kendall beige","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":26,"Nombre":"Ramio natural","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":39,"Nombre":"Rustico 2604","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":40,"Nombre":"Rustico 3222","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":41,"Nombre":"Congo Marfil","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":42,"Nombre":"Camerún beige","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":43,"Nombre":"Rustico 3070","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":44,"Nombre":"Ramio Blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":45,"Nombre":"Ramio Marfil","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":46,"Nombre":"Uganda Tostado","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":2,"Nombre":"FIBRA VEGETAL"}},{"ID":47,"Nombre":"Uganda Marrón","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":2,"Nombre":"FIBRA VEGETAL"}},{"ID":48,"Nombre":"Uganda Crema","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":2,"Nombre":"FIBRA VEGETAL"}},{"ID":49,"Nombre":"Uganda Beige","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":2,"Nombre":"FIBRA VEGETAL"}},{"ID":50,"Nombre":"Nilo Natural","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":14,"Nombre":"ALGODÓN Y POLIÉSTER TRANSLÚCIDO"}},{"ID":51,"Nombre":"Nilo Marfil","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":14,"Nombre":"ALGODÓN Y POLIÉSTER TRANSLÚCIDO"}},{"ID":52,"Nombre":"Nilo Beige","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":14,"Nombre":"ALGODÓN Y POLIÉSTER TRANSLÚCIDO"}},{"ID":53,"Nombre":"Bicolor 2958 marrón","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":54,"Nombre":"Bicolor 2958 marfil","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":11,"Nombre":"LISOS Y RUSTICOS"}},{"ID":55,"Nombre":"Amazonia Blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":14,"Nombre":"ALGODÓN Y POLIÉSTER TRANSLÚCIDO"}},{"ID":56,"Nombre":"Liso 2861 Marfil","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":14,"Nombre":"ALGODÓN Y POLIÉSTER TRANSLÚCIDO"}},{"ID":57,"Nombre":"Blanco / blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":13,"Nombre":"BLACKOUT TEXTIL"}},{"ID":58,"Nombre":"Blanco / beige","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":13,"Nombre":"BLACKOUT TEXTIL"}},{"ID":59,"Nombre":"Natural","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":60,"Nombre":"Blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":61,"Nombre":"Gris","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":62,"Nombre":"Negro","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":96,"Nombre":"BEIGE / BICOLOR","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":13,"Nombre":"BLACKOUT TEXTIL"}},{"ID":99,"Nombre":"Negro","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":3,"Nombre":"5% POLIESTER"}},{"ID":120,"Nombre":"Gris","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":3,"Nombre":"5% POLIESTER"}},{"ID":121,"Nombre":"Beige","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":3,"Nombre":"5% POLIESTER"}},{"ID":122,"Nombre":"Verde","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":123,"Nombre":"Chocolate","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":124,"Nombre":"Celeste grisáceo","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":125,"Nombre":"Negro / blanco","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"}},{"ID":126,"Nombre":"marrón / negro","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":3,"Nombre":"5% POLIESTER"}},{"ID":127,"Nombre":"plata - negro","Marca":{"ID":1,"Nombre":"Genérica"},"Material":{"ID":3,"Nombre":"5% POLIESTER"}},{"ID":27,"Nombre":"E screen white / linen","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":67,"Nombre":"E screen 1% white / white","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":7,"Nombre":"1% FIBERGLASS"}},{"ID":68,"Nombre":"E screen 1% white / pearl","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":7,"Nombre":"1% FIBERGLASS"}},{"ID":69,"Nombre":"E screen 1% white / linen","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":7,"Nombre":"1% FIBERGLASS"}},{"ID":70,"Nombre":"E screen 3% white / white","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":8,"Nombre":"3% FIBERGLASS"}},{"ID":71,"Nombre":"E screen 3% white / pearl","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":8,"Nombre":"3% FIBERGLASS"}},{"ID":72,"Nombre":"E screen 3% white / linen","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":8,"Nombre":"3% FIBERGLASS"}},{"ID":73,"Nombre":"Edessa Beach","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":74,"Nombre":"Edessa Glacier","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":75,"Nombre":"S screen Patina","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":9,"Nombre":"4% FIBERGLASS"}},{"ID":76,"Nombre":"S screen Porcelain","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":9,"Nombre":"4% FIBERGLASS"}},{"ID":77,"Nombre":"S screen Papyrus","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":9,"Nombre":"4% FIBERGLASS"}},{"ID":78,"Nombre":"S screen Granite","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":9,"Nombre":"4% FIBERGLASS"}},{"ID":79,"Nombre":"S screen Carbon","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":9,"Nombre":"4% FIBERGLASS"}},{"ID":80,"Nombre":"E screen white / white","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":81,"Nombre":"E screen white / pearl","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":82,"Nombre":"E screen linen / linen","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":83,"Nombre":"A screen  white / white","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":10,"Nombre":"14% FIBERGLASS"}},{"ID":84,"Nombre":"A screen White / Sable","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":10,"Nombre":"14% FIBERGLASS"}},{"ID":85,"Nombre":"A screen Charcoal / linen","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":10,"Nombre":"14% FIBERGLASS"}},{"ID":86,"Nombre":"A screen Charcoal / charcoal","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":10,"Nombre":"14% FIBERGLASS"}},{"ID":87,"Nombre":"A screen white / pearl","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":10,"Nombre":"14% FIBERGLASS"}},{"ID":88,"Nombre":"E screen charcoal / cocoa","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":90,"Nombre":"E screen charcoal / charcoal","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":91,"Nombre":"M Screen charcoal / apricot","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":92,"Nombre":"M screen cocoa / brick facade-fall","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":93,"Nombre":"M Screen pearl / pearl","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":94,"Nombre":"M Screen Linen / Sable Cocoa","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":95,"Nombre":"M screen charcoal / grey","Marca":{"ID":2,"Nombre":"Mermet"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":63,"Nombre":"Natte 380 blanco / perla","Marca":{"ID":3,"Nombre":"Copaco"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":64,"Nombre":"Natte 380 blanco","Marca":{"ID":3,"Nombre":"Copaco"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":65,"Nombre":"Natte 380 blanco / lino","Marca":{"ID":3,"Nombre":"Copaco"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":66,"Nombre":"Natte 380 negro","Marca":{"ID":3,"Nombre":"Copaco"},"Material":{"ID":5,"Nombre":"5% FIBERGLASS"}},{"ID":21,"Nombre":"Kendall blanco","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":22,"Nombre":"Kendall arena","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":24,"Nombre":"Kendall cemento","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":25,"Nombre":"Kendall marrón","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":28,"Nombre":"South beach ebony","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":29,"Nombre":"South beach white","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":6,"Nombre":"ACRÍLICO TRANSLÚCIDO"}},{"ID":30,"Nombre":"South beach ivory","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":6,"Nombre":"ACRÍLICO TRANSLÚCIDO"}},{"ID":31,"Nombre":"South beach stone","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":6,"Nombre":"ACRÍLICO TRANSLÚCIDO"}},{"ID":32,"Nombre":"South beach bordeaux","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":6,"Nombre":"ACRÍLICO TRANSLÚCIDO"}},{"ID":33,"Nombre":"South beach navy","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":6,"Nombre":"ACRÍLICO TRANSLÚCIDO"}},{"ID":34,"Nombre":"South beach ebony","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":6,"Nombre":"ACRÍLICO TRANSLÚCIDO"}},{"ID":35,"Nombre":"South beach white","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":36,"Nombre":"South beach ivory","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":37,"Nombre":"South beach stone","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":38,"Nombre":"South beach bordeaux","Marca":{"ID":4,"Nombre":"Vertilux"},"Material":{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"}},{"ID":97,"Nombre":"Masacril amarillo","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":100,"Nombre":"Masacril Azul","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":101,"Nombre":"Masacril Azul Marino","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":102,"Nombre":"Masacril Azul Real","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":103,"Nombre":"Masacril Beige","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":104,"Nombre":"Masacril Beige X","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":105,"Nombre":"Masacril Berna","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":106,"Nombre":"Masacril Blanco","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":107,"Nombre":"Masacril Café","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":108,"Nombre":"Masacril Canigo","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":109,"Nombre":"Masacril Capri","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":110,"Nombre":"Masacril Crema","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":111,"Nombre":"Masacril Granate","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":112,"Nombre":"Masacril Gris","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":113,"Nombre":"Masacril Jade","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":114,"Nombre":"Masacril Jamaica","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":115,"Nombre":"Masacril Madeira","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":116,"Nombre":"Masacril Maíz","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":117,"Nombre":"Masacril Marfil","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}},{"ID":119,"Nombre":"Masacril Marrón","Marca":{"ID":5,"Nombre":"Sauleda"},"Material":{"ID":15,"Nombre":"ACRILICO COLORIDO"}}];

    $scope.marcas = [{"ID":1,"Nombre":"Genérica"},{"ID":2,"Nombre":"Mermet"},{"ID":3,"Nombre":"Copaco"},{"ID":4,"Nombre":"Vertilux"},{"ID":5,"Nombre":"Sauleda"}];

    $scope.materiales = [{"ID":1,"Nombre":"BLACKOUT VINILICO PREMIUM"},{"ID":2,"Nombre":"FIBRA VEGETAL"},{"ID":3,"Nombre":"5% POLIESTER"},{"ID":4,"Nombre":"BLACKOUT VINILO / TEXTIL"},{"ID":5,"Nombre":"5% FIBERGLASS"},{"ID":6,"Nombre":"ACRÍLICO TRANSLÚCIDO"},{"ID":7,"Nombre":"1% FIBERGLASS"},{"ID":8,"Nombre":"3% FIBERGLASS"},{"ID":9,"Nombre":"4% FIBERGLASS"},{"ID":10,"Nombre":"14% FIBERGLASS"},{"ID":11,"Nombre":"LISOS Y RUSTICOS"},{"ID":12,"Nombre":"BLACKOUT VINILICO ECO"},{"ID":13,"Nombre":"BLACKOUT TEXTIL"},{"ID":14,"Nombre":"ALGODÓN Y POLIÉSTER TRANSLÚCIDO"},{"ID":15,"Nombre":"ACRILICO COLORIDO"}];


    $scope.resultado= $scope.materiales.map(function(material){
        material.Marcas = $scope.marcas.map(function(marca){
            marca.Telas = $scope.telas.filter(function(tela){
              return tela.Material.ID == material.ID && tela.Marca.ID == marca.ID;
            });
            return marca;
        });
        return material
		});
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
  <ul ng-repeat="material in materiales">
    <li>{{ material.Nombre }}</li>
    <ul ng-repeat="marca in material.Marcas">
      <li>{{ marca.Nombre }}</li>
      <ul ng-repeat="tela in marca.Telas">
        <li>{{ tela.ID + " - " + tela.Nombre }}</li>
      </ul>
    </ul>
  </ul>
</div>

As you can see in the result variable, what I try to do is: For each material, add a field of "brands", with all the brands and also, within each brand, a field of "fabrics" with all the fabrics filtered by the brand / parent material, something like this:

result = [Material_1, Material_2, ..., Material_n], where

Material_i = {Material_ID, Material_Name, Markings} (fields)

and Marks = [Brand_1, ..., Brand_i], where

Marca_i = {ID_Marca, Nombre_Marca, Fabrics}, where

Fabrics = Fabrics filtered by ID_Marca and ID_Material

I am not understanding why you order this way, since you are not arranging the fabrics in your material / brand and repeat 20 fabrics (out of 50) in the same brand / material

Thanks for your help Greetings!

    
asked by John P. 15.10.2017 в 21:15
source

1 answer

0

Your code should be as follows

var marcas  = $scope.marcas.map(function(marca) {
        var materiales = $scope.materiales.map(function(material){
            var telas = $scope.telas.filter(function(tela) {
                return tela.Marca.ID == marca.ID &&
                    tela.Material.ID == material.ID;
            }).map(function(tela) {
                return {
                    id: tela.ID,
                    nombre: tela.Nombre
                };
            });
            return {
                material: material,
                telas: telas
            };
        });
        return {
            marca: marca,
            materiales: materiales
        };
    });

And your DOM could look like this:

<ul ng-repeat="item in marcas">
    {{item.marca.Nombre}}
    <li ng-repeat="materialItem in item.materiales">
        {{materialItem.material.Nombre}}
        Telas: {{materialItem.telas.length}}
    </li>
</ul>
    
answered by 19.10.2017 в 21:29