F
F
Friend2016-10-19 20:14:02
JavaScript
Friend, 2016-10-19 20:14:02

How to pull value in html from own filter?

My filter:

iApp.filter('filtermaterials', function () {
        return function (doors, wood, plastic) {
            if(doors == null) return;
        var filteredMaterials = [];
        if (wood === undefined){
            wood = "";
        }if (plastic === undefined){
            plastic = "";
        }
        if (wood === "" && plastic === ""){
            wood = "Дерево";
            plastic = "Пластик";
        }
        for (var i = 0; i < doors.length; i++) {
            if (String(doors[i]['type']) === String(wood)) {
                filteredMaterials.push(doors[i]);
            }
            if (String(doors[i]['type']) === String(plastic)){
                filteredMaterials.push(doors[i]);
            }
        }
        return filteredMaterials;
        };
});

How can I pull the value outside the loop block
<div class="mybodydivright2" align="center" ng-repeat="door in doors | filtermaterials:wood:plastic | filtercompani:one:two | filterprice:price1:price2 | orderBy:price">
    {% verbatim %}
    {{door.name}}<br>
    <img src={{door.img}} width="150" height="200"><br>
    Фирма: {{door.star}}<br>
    Материал: {{door.type}}<br>
    Цена: {{door.price}}
    {% endverbatim %}
</div>

Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Friend, 2016-10-20
@Tiran_94

I tried to pull it out using the new allfilter filter in which I sort through and select what I need, though at the end I change the doors array, it displays what I wanted!)) And a huge error is flying here is the main part of
Please tell me what to do?)

<span ng-repeat="door in doors | allfilter:one:two:price1:price2">{% verbatim %}
 <input type="checkbox" ng-model='one' ng-true-value="'Дерево'" ng-false-value="" /> Первый {{ door.nameone }}<br>
        <input type="checkbox" ng-model='two' ng-true-value="'Дерево'" ng-false-value="" /> Второй {{ door.nametwo }}<br><br>
{% endverbatim %}</span>

iApp.filter('allfilter', function () {
        return function (doors, one, two, price1, price2) {
        if(doors == null) return;
        var filteredMaterials = [];
        console.log(filteredMaterials);
        filteredMaterials.push({'nameone': 10, 'nametwo': 20});
        return filteredMaterials;
        };

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question