这是我来自 Angular 的代码(带有重命名的方法):
我有一个函数接口/契约
type IAutocomlete = (
term: string,
selectedIds?: string[]
) => Observable<TableFilterQueryResponse[]>;
Run Code Online (Sandbox Code Playgroud)
这是我将来要注入到我的组件中的草稿服务。我会有更多类似实现的方法。
export class SuperCleanService {
constructor(
private dataController: DataController,
private serviceController: ServiceController
) {}
.....
private searchAs$: IAutocomlete = (term, selectedIds) => {
return this.dataController
.service1GET(term, selectedIds)
.pipe(
map((res) =>
res.map((a) => ({
viewValue: a.name,
value: a.id
}))
)
);
};
private searchB$: IAutocomlete = (term, selectedIds) => {
return this.serviceController
.service1(term, selectedIds)
.pipe(
map((res) =>
res.map((a) => ({
viewValue: a.id,
value: a.id
}))
) …Run Code Online (Sandbox Code Playgroud)