A
A
Alexey Belov2018-02-24 13:36:38
JavaScript
Alexey Belov, 2018-02-24 13:36:38

How to filter an array in AnuglarJS?

How to filter the array so that only one element with id=250380 is knocked out, instead of the entire array
Api: monoapi.steigenhaus.com/index.php/json/api/products

var  loadProducts = function () {

            return $q(function (resolve,reject) {
                $http.get(getProductsUrl)
                    .then(function (res) {
                        // popular = res.data.popular;
                        catalog = res.data.categories;

                        AppState.setField('productsLoaded',true); // Каталог продуктов загружен

                        var i,j;
                        
                        
                        // популярные шаблоны продуктов в массив с шаблонами
                        for(i=0; i<popular.length; i++){
                            templates[popular[i].id] = {
                                name: popular[i].name,
                                loaded: false,
                                loading: false
                            };
                        }

                        // все остальные шаблоны продуктов в массив с шаблонами
                        for(i=0; i<catalog.length; i++){
                            for(j=0; j<catalog[i].templates.length; j++){
                                templates[catalog[i].templates[j].id] = {
                                    name: catalog[i].templates[j].name,
                                    loaded: false,
                                    loading: false
                                };
                            }
                        }

                        resolve();

                    })
                    .catch(function (err) {
                        console.log('Error',err);
                        reject(err);
                    });
            });


        };

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question