我正在使用Angular7和ngrx/store,我有一些逻辑非常复杂的组件。它在组件级别注入了不同的服务:
providers: [Service1, Service2]
UpdateComponentPresentation
@Effect({ dispatch: false })
updatePresentation$ = this.actions$.pipe(
ofType(UpdateComponentPresentation),
map((action) => {
const someComponentId = action.payload.id;
const service1 = getComponentServiceInstanceById(id);
this.service.rerender();
})
);
那么,是否有可能以某种方式使组件服务的实例生效呢?服务应该在组件级别注入是很重要的,因为我可以在页面上同时拥有多个组件。在这些服务中,我有许多与当前组件实例相关的内部数据。