Tuesday, 21 March 2017

What are the services, its need and benefits ?


SERVICES
  • Service is an object which provides some services like, Utilities, Business logic
    Examples : $http, $log,
  • Services can be reused in Controllers, custom Directives and custom Filters.
  • Custom services can also be created

NEED OF SERVICE
  • Controller should not do all the business logic or a complex logic.
    Instead, it must call different services in order to perform action.

BENEFITS
  • Reusability - Reusable in Controllers, Directives and Filters
  • Dependency injection - can be injected in Controller
  • Easy to Test - Pass mock objects to test services

No comments:

Post a Comment

Note: only a member of this blog may post a comment.