我正在使用带有打字稿的1.5角。面对Unknown provider: testNameFilterFilterProvider <- testNameFilterFilter
这是我现有的代码
export class TestNameFilter extends AbstractFilter {
public static factory($injector: angular.auto.IInjectorService): Function {
return new TestNameFilter($injector).filter;
}
public constructor($injector: angular.auto.IInjectorService) {
super("TestNameFilter", $injector);
}
public filter = (text: string, length: any, end: any): string => {
let state: string = text;
state = this.toSentenceCase(state);
return state;
}
}
注册
angular.module("myApp").filter(
"testNameFilter",
[
"$injector",
($injector: angular.auto.IInjectorService) => new TestNameFilter($injector).filter,
]
);
HTML
<select
ng-options="item as (test.name | testNameFilter)
for test in testing">
<option value=""></option>
</select>