backbone-style models in angularjs?

前端 未结 1 1147
囚心锁ツ
囚心锁ツ 2021-01-12 09:53

I apologize if this question has already been answered elsewhere, but I couldn\'t find a full, obvious (to me, at least) solution.

I have experience with the idea of

1条回答
  •  借酒劲吻你
    2021-01-12 10:28

    In Angular models are just a POJOs (plain old javascript objects).

    Services are something different, but you'll usually fetch the models with services. It is a good practice to have more services, so you can reuse them throughout your application. Also a big plus for services is, that they can be unit tested. And like everything else in software engineering, it's always better to split your application into little modules which are easier to maintain than a big chucks of code.

    You don't need to just mimic your models as service. You can later add some functions to them and keep your domain logic inside those services.

    I'm not an Angular specialist, but I hope this can help.

    0 讨论(0)
提交回复
热议问题