@dimas09 wrote:
I have the component
Scheduleand call it like:{{schedule-show currentSupplier=supplier currentVisitor=visitor}}This component retrives
EventsofSupplierand draw this events on the calendar. The component has actions to manipulate with events.I want to encapsulate all business-logic for actions with events in the service
Event. This service should depends on current supplier, current visitor, current event. The service is singleton so when one of models is changed I need to change it in the service.For example, I need property
canEditI to check:
- if the current user is an admin return true OR
- if the current user is a visitor and visitor owns the current event OR
- if the current user is a supplier and supplier owns the current event OR
I have
CurrentUserservice and I can inject it toEventservice.But how to inject current event to the service in right way?
For example, I need method
create. To create the event I need pass current state of the form to the service also I need thecurrentSupplierandcurrentVisitor. In this case I could pass as arguments of method.The service has finite number of dependencies. What is the right way to inject dependencies like that?
I think in methods I could make in next way:
create(properties) { this.setPropeties(properties); doSomeLogic............. }For computed properties
property(name, properties) { this.setPropeties(properties); return this.get(name); }
Posts: 1
Participants: 1