慢慢入门吧,不着急。
至少知道了controller和service的分工。
new function时,隐含有用this指向function的prototype之意。
这样,两个JAVASCRIPT难点,作用域及原型域得以统一。
故有的书上讲,javascript的funciton定义中,其它的都是语法糖,正宗的还是这个new关键字的函数式编程的定义。
PERFETC!!!
http://tylermcginnis.com/angularjs-factory-vs-service-vs-provider/
AngularJS: Factory vs Service vs Provider
When you first get started with Angular, you’ll naturally find yourself flooding your controllers and scopes with unnecessary logic. It’s important to realize early on that your controller should be very thin; meaning, most of the business logic and persistent data in your application should be taken care of or stored in a service. I see a few questions a day on Stack Overflow regarding someone trying to have persistent data in his or her controller. That’s just not the purpose of a controller. For memory purposes, controllers are instantiated only when they are needed and discarded when they are not. Because of this, every time you switch a route or reload a page, Angular cleans up the current controller. Services however provide a means for keeping data around for the lifetime of an application while they also can be used across different controllers in a consistent manner.
Angular provides us with three ways to create and register our own service.
1) Factory
2) Service
3) Provider