我有两个服务和一个角度。第一个负责数据操作,并且还有一些返回数据的方法。第二个负责数据渲染。 RenderingService 使用 DataManipulationService 中的两个方法。如何使用接口隔离原则仅提供对这两种方法的访问,而不添加新的类或服务类型化作为接口?对于其余的方法,我无法访问。不考虑使用私有修改器的解决方案,因为该服务在应用程序的其他部分使用。
我可以提供一些我解决这个问题的错误尝试
我将不胜感激任何帮助。
您可以简单地为您的所有服务方法使用原生
private
和 public
关键字。
public myPublicMethod() { // do something public }
private myPrivateMethod() { // do something very secret }