Improve module.filter() by allowing $stateful to be defined.

This commit is contained in:
Oscar Busk
2018-06-28 12:27:49 +02:00
parent 80d50f06cf
commit f6a902f8ce
2 changed files with 22 additions and 6 deletions

View File

@@ -214,11 +214,18 @@ mod.factory({
name1(foo: any) {},
name2: ['foo', (foo: any) => {}]
});
mod.filter('name', ($scope: ng.IScope) => {});
mod.filter('name', ['$scope', ($scope: ng.IScope) => {}]);
mod.filter('name', ($scope: ng.IScope) => () => {});
mod.filter('name', ['$scope', ($scope: ng.IScope) => () => {}]);
mod.filter({
name1(foo: any) {},
name2: ['foo', (foo: any) => {}]
name1(foo: any) { return () => {}; },
name2: ['foo', (foo: any) => () => {}],
});
const customStatefulFilter: ng.FilterFunction<(s: string) => number> = (s) => 1;
mod.filter('name', () => customStatefulFilter);
mod.filter('name', ['$scope', () => customStatefulFilter]);
mod.filter({
name1: () => customStatefulFilter,
name2: ['foo', () => customStatefulFilter],
});
mod.provider('name', ($scope: ng.IScope) => ({ $get: () => { } }));
mod.provider('name', TestProvider);