问题
Both routes and controllers are singleton classes, so why not just do Ember.Route.create() or Ember.Controller.create() ?
回答1:
This is only a guess, but I would imagine because this way is more versatile. Yes, controllers and routes and singletons now, but they might not always be. If Ember decides tomorrow that controllers no longer need to be singletons, you don't have to change the way you've declared your controllers. (I think there might even be a way in the container to make it so your controllers and routes are not singletons. I wouldn't recommend it though.)
There's also a few other smaller benefits. You can extend classes but not objects, so declaring them as classes allows code reuse. Also, you can't declare computed properties at creation time, so you'd have to do Ember.Controller.extend().create()
anyway.
回答2:
Whenever we define a new route or controller then we are basically creating a new instance of that route or controller. We do it using create method, so that we can override any method hooks if required. So in short for each route and controller we have different instances( not a single instance). In case of Ember application we use create method because we can have only one application instance, but we can have more than one routes , controllers, views, so we use extend method .
来源:https://stackoverflow.com/questions/28672870/why-are-routes-and-controllers-classes-and-not-objects