Should I use readonly on injected Angular services instead of making them public?
问题 I had a discussion today where some of my colleagues said that they inject their Angular services like that: constructor(readonly language: I18nService) They said they do this because it prevents consumers of my component to change the injected service, kinda like that: @Component({ ... }) class ComponentA { constructor(public language: I18nService) {} } @Component({ ... }) class ComponentB { @ViewChild(ComponentA) compA: ComponentA; constructor() { this.compA.language = new I18nService(); }