AngularJS Models

前端 未结 1 826
夕颜
夕颜 2021-01-03 08:56

I\'m trying to wrap my head around AngularJS. I\'m liking a lot of it, but a core concept seems to be escaping me – where are the models?

If I have an application, f

相关标签:
1条回答
  • 2021-01-03 09:10

    The thing about Angular is that it leaves the model up to you. You don't have to extend some built in object to make it work, it can be any object you want.

    a) Yes, but like I said, that's up to you. You can even use Backbones model implementation if you'd like.

    b) Probably in your model object. Angular offers a resource service which you can use. You can define your own methods on those resources, so that'd be a good starting point.

    c) Do you mean the GUI part or business logic? Angular handles the GUI for you. Just implement the function that removes the transaction from the list, and Angular will re-render it for you.

    d) Again, that's up to you to implement or use a library for. Angular is mostly a GUI framework with very little opinion about your model/persistance layer.

    For your last question; you would place most of the logic in services. Your Angular controllers would be injected with the services they need, and expose functionality to the view through the scope. You should avoid adding things to the root scope as much as possible, since they will essentially be global in your templates.

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