Ember.js: convert application to Router API V2

I am new to Ember.js, and when developing the application, I just learned about the new router API. which was combined and has no documentation at all (except for this - https://gist.github.com/3981133 )

I don’t know how to start converting my application into the new router API. this “walkthrough” doesn't help much.

1) how to connect templates to named points, for example {{outlet main}}?

2) I use App.router.someController and App.router.get ('store'). findAll () and .find () for everything that needs to be replaced?

3) are there any changes to the handlebars tag in html <script type="text/x-handlebars" data-template-name="templateName"> ?

that is all i can think of now.

+4
source share
1 answer

I just finished this update myself on a small project example

https://github.com/toranb/ember-code-camp

To answer a few questions directly

1) there is no longer connectOutlets noise - just map the route to the ember route class / object. this approach is very conditionally based on btw (template / view / controller / route all match)

 CodeCamp.Router.map(function(match) { match("/").to("sessions"); match("/session/:session_id").to("session"); //no route needed -ember will apply the context for you match("/speaker/:speaker_id").to("speaker"); //same as above so long as my handlebars template name matches (speaker for this route) }); CodeCamp.SessionsRoute = Ember.Route.extend({ setupControllers: function(controller) { controller.set('content', CodeCamp.Session.find()); } }); 

2 a) you get storage in the router so

 App.YourObject.find() 

2 b) you can commit storage from your controller in this way

 this.get('store').commit() 

3) my things with rudders remained unchanged, with the exception of assistants associated with the routes.

 I remove action helpers defined with <a {{action and used linkTo instead {{#linkTo 'session' session}}View Session Details{{/linkTo}} 
+5
source

All Articles