Vova Aleshchenko
Vova Aleshchenko

Reputation: 33

How can I provide access only for some methods from service in angular?

I have a two services an angular. The first one responsible for data manipulation and also has some methods which return data. The second one responsible for data rendering. RenderingService use two methods from DataManipulationService. How can I provide access only to these two methods with interface segregation principle without adding a new classes or service typization as an interface? For rest of methods I haven't to get access. Solution with private modificators isn't considering because this service uses in other parts of application.

I can provide some of my wrong attempts of solutions of this problem

I will be apreciate for any help.

enter image description here

enter image description here

Upvotes: 0

Views: 74

Answers (1)

JoannaFalkowska
JoannaFalkowska

Reputation: 3677

You can simply use the native private and public keywords for all your service methods.

public myPublicMethod() { // do something public }

private myPrivateMethod() { // do something very secret }

Upvotes: 0

Related Questions