This is an coding exmaple of Single Responsibility Principle of a Class using a service and Dependency Injection for code reuse. Components use to display and present data. Services use to fetch the data from the API. Components should not fetchdata or save data. Rather they should focus on representing data and delegate data access to a Service. Services is a great way to share informaton among classes THAT DO NOT KNOW EACH OTHER. Therefore when you run across a scenario in which you need to use the same code across mulitple components.
- Clone down repo
- Run npm install
- Run ng serve
Angular cli 7 Services
Jan 18, 2018 Rouz Majlessi
www.rouzm.com