javascriptangularjsangular-data

Substring filter on angular-data resource


DEFAULT_RECORDS = [{ id: 1, name: 'John Evans', number: '01928 356115' },{ id: 16, name: 'Murbinator', number: '053180 080000' }];

-

lookup: function (name) {
            var retrievedRecords = {};
            var _this = this;
            Record.findAll().then(function () {
                var params = {
                    where: {
                        name: {
                            'in': name
                        }
                    }
                };
                retrievedRecords = Record.filter(params);
                debugger;
                _this.lookupSuccess(retrievedRecords);
            }).catch(function (error) {
                console.log(error);
            });
        },

Where 'in': name is "John" no record is found

Where 'in': name is "John Evans" one record is found.

Looking at angular-data issue 238 that appears to be the way I should be filtering but is not the value I expect to be return for sub-string filtering.

I can't figure out why no records are returned for the sub-string filter at the point debugger stops execution.

angular-data : 1.5.3 angular : 1.3.8


Solution

  • You're looking for 'contains' not 'in'. Looks like this feature was added a little after the issue you posted (259)