0
votes

I'm new to ember js.

I'm confused about why there is already has a Router to map the url request to a dedicated resource, and there are still exsisting route for each resource.

For example, http://{SITE}/product will redirect to product resource,

and the route rule is defined in the router.

(Because router's responsibility is routing something,it's self-explanatory)

But I have no ideas why should ember needs routes

It seems it's NOT related to route.

What is it for ? Its name 'route' is confusing me :(

And it looks like to handle something about construction/initialization to setup how its controller/model to be init? (is my guess correct?)

enter image description here

1
your guess is mostly correct about Ember.Route in the sense that it inits all the artifacts used by a given resource: Model data, controller's initialization and injection (if needed), view layer (render options), etc. Please visit the link @Kingpin2k addedMilkyWayJoe

1 Answers

2
votes

The router defines possible urls that can be hit.

Routes are most commonly used for specifying the model associated with that particular portion of the url.

 `/photos`

would associate with

App.PhotosRoute = Ember.Route.extend({
  model: function(){
    return listOfPhotos;
  }
});

You should go through the documentation to gain a better understanding: http://emberjs.com/guides/routing/