I was using filter:query on a json response to filter. Everything worked fine. When I turned the json response into proper classes the filter stopped working. What is the approach to use query to match fields on a class? Is this the situation where I should then create my own custom @NgFilter?
相关问题
- What means in Dart static type and why it differs
- Flutter : Prepare list data from http request
- How to schedule an alarm on specific time in Flutt
- MappedListIterable is not a SubType
- What is the difference between generics and dynami
相关文章
- Observatory server failed to start - Fails to crea
- Adding Shadows at the bottom of a container in flu
- Flutter. Check if a file exists before loading it
- Receive share file intents with Flutter
- Do stateless widgets dispose on their own?
- how to implement Alphabet scroll in flutter
- Flutter: Is it possible to format (bold, italicize
- Make Function parameter optional in custom widget
For the AngularDart
filter
filter you specify which fields to match on by passing the field names as the keys to a map.Let us use the AngularDart tutorial
Recipe
class as an example:You can filter, e.g., on
Recipe.name
using the stringctrl.nameFilterString
write:Here is an excerpt from the
filter
API doc that explains howfilter
interprets its argument. I.e. inthe argument
x
can be aString
,bool
andnum
: Only items in theList
that directly match this expression, items that are Maps with any value matching this item and items that are Lists containing a matching items are returned.Map
: This defines a pattern map. Filters specific properties on objects contained in the input List. For example{name:"M", phone:"1"}
predicate will return a list of items which have propertyname
containing "M" and propertyphone
containing "1". A special property name,$
, can be used (as in{$: "text"}
) to accept a match against any property of the object. That's equivalent to the simple substring match with aString
as described above.I'm not sure what you mean by 'filter:query'. I guess it is the filter
filter
.filter
seems to convert the items in the collection to string and compares them with the search text. If thetoString()
doesn't contain the field you want to compare it won't match.A custom filter is probably the best option.
Example:
angular.dart.tutorial / Chapter_07 / lib / filter / category_filter.dart