简体   繁体   中英

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?)

在此处输入图片说明

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM