newBike
newBike

Reputation: 15002

Why ember needs Route ? or why it called route

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

Upvotes: 0

Views: 39

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

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/

Upvotes: 2

Related Questions