Why use services in Angular?

前端 未结 5 1082
甜味超标
甜味超标 2020-12-06 05:15

I am just starting out with Angular. Reading the example of a service in the Google documentation, I just wonder why you would choose to use a service rather keeping the var

5条回答
  •  时光说笑
    2020-12-06 05:55

    Apart from the benefits listed above, it also helps you divide your application structure into independent components, which make it more understandable and testable as well.

    Imagine having to test similar functionality at multiple places rather than having it defined/debugged at a central location and used elsewhere (multiple times).

提交回复
热议问题