Andrey Pavlyuk2016-09-23 15:38:47
Andrey Pavlyuk, 2016-09-23 15:38:47

AngularJS: How to filter object (Error: [filter:notarray])?

There is a data object for forming a select tag through angular.

"name":"Group 1: №1",

An html object is formed from this template (used controlerAs):
<select ng-model="row.ID" ng-options="row_item.ID as row_item.name disable when row_item.disable for row_item in app.data.rows | filter:rowDisabled" class="form-control"></select>

There is a function in the controller, according to which the select data should be filtered and row_item.disable = true should be set for certain items.
BilCtrl.rowDisabled = function() {
        return function (rows) {
            var result = {};
            angular.forEach(rows, function(row, key) {
                row.disable = false;
                if( row_item.buyed )
                    row.disable = true;
                for( var i in BilCtrl.rows ){
                    if (!BilCtrl.rows.hasOwnProperty(i))
                    if( BilCtrl.rows[i].ID == row.ID )
                        row.disable = true;
                result[key] = row;
            return result;

But this beauty gives me an error: Error: [filter: notarray]
I still couldn't apply the filter. Can't filters be applied to objects? Only arrays? In the example, they use for the object ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Vladimir, 2016-09-23

In general, custom filters are written differently
Section Creating custom filters

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question