Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/directive/ng_repeat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ class NgRepeatDirective extends AbstractNgRepeatDirective {
BoundBlockFactory boundBlockFactory,
Scope scope,
Parser parser,
AstParser astParser)
: super(blockHole, boundBlockFactory, scope, parser, astParser);
AstParser astParser,
FilterMap filters)
: super(blockHole, boundBlockFactory, scope, parser, astParser, filters);
}

/**
Expand Down Expand Up @@ -118,8 +119,9 @@ class NgShallowRepeatDirective extends AbstractNgRepeatDirective {
BoundBlockFactory boundBlockFactory,
Scope scope,
Parser parser,
AstParser astParser)
: super(blockHole, boundBlockFactory, scope, parser, astParser)
AstParser astParser,
FilterMap filters)
: super(blockHole, boundBlockFactory, scope, parser, astParser, filters)
{
print('DEPRECATED: [ng-shallow-repeat] use [ng-repeat]');
}
Expand All @@ -134,6 +136,7 @@ abstract class AbstractNgRepeatDirective {
final Scope _scope;
final Parser _parser;
final AstParser _astParser;
final FilterMap filters;

String _expression;
String _valueIdentifier;
Expand All @@ -145,7 +148,8 @@ abstract class AbstractNgRepeatDirective {
Iterable _lastCollection;

AbstractNgRepeatDirective(this._blockHole, this._boundBlockFactory,
this._scope, this._parser, this._astParser);
this._scope, this._parser, this._astParser,
this.filters);

set expression(value) {
_expression = value;
Expand Down Expand Up @@ -181,7 +185,7 @@ abstract class AbstractNgRepeatDirective {
_keyIdentifier = match.group(2);

_watch = _scope.watch(
_astParser(_listExpr, collection: true),
_astParser(_listExpr, collection: true, filters: filters),
(CollectionChangeRecord collection, _) {
//TODO(misko): we should take advantage of the CollectionChangeRecord!
_onCollectionChange(collection == null ? [] : collection.iterable);
Expand Down
10 changes: 10 additions & 0 deletions test/directive/ng_repeat_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ main() {
});


it('should support filters', () {
element = $compile(
'<div><span ng-repeat="item in items | filter:myFilter">{{item}}</span></div>');
scope.context['items'] = ['foo', 'bar', 'baz'];
scope.context['myFilter'] = (String item) => item.startsWith('b');
scope.apply();
expect(element.find('span').length).toEqual(2);
});


describe('track by', () {
it(r'should track using expression function', () {
element = $compile(
Expand Down