tutorial template started getting example ember data create component ember.js ember-router

template - nuevo enrutamiento ember.js: cómo conectar puntos de venta?



ember js windows (2)

Estoy confundido sobre cómo conectar enchufes con el nuevo enfoque de enrutador.

index.html:

... <script type="text/x-handlebars" data-template-name="application"> <h4>The application handelbar</h4> {{! outlet 1}} {{outlet}} </script> <script type="text/x-handlebars" data-template-name="index"> <h4>The index handelbar</h4> {{! outlet 2 and 3}} {{outlet nav}} {{outlet main}} </script> <script type="text/x-handlebars" data-template-name="main"> <h4>The main handelbar</h4> </script> <script type="text/x-handlebars" data-template-name="nav"> <h4>The nav handelbar</h4> </script> ...

app.js:

... App.Router.map(function(match) { this.resource("index", { path: "/" }); this.route("test"); }); App.IndexController = Ember.Controller.extend({ }); App.IndexView = Ember.View.extend({ templateName: ''index'' }); ...

Este código representa la salida-1.

Preguntas:

  • ¿Por qué se emite outlet-1? ¿Cómo están conectados el outlet-1 y el "índice"?
  • ¿Cómo puedo conectar las salidas 2 y 3 al mismo sitio de "índice"?

Gracias
miw


Debe especificar esto en un controlador de ruta, utilizando el método renderTemplate (o el método renderTemplates, dependiendo de su compilación).

Lo que no está viendo es que Ember ya está estableciendo algunos valores predeterminados para usted. De hecho, los valores predeterminados establecidos por Ember le permitieron omitir todo el manejador de ruta.

App.Router.map(function(match) { this.resource("index", { path: "/" }); this.route("test"); }); App.IndexRoute = Ember.Route.extend({ renderTemplate: function() { this.render(); /* this is the default, it will basically render the default template, in this case ''index'', into the application template, into the main outlet (i.e. your outlet 1), and set the controller to be IndexController. */ } });

Lo que desea es representar plantillas adicionales en la función renderTemplate, me gustao:

renderTemplate: function() { this.render("index"); // this renders the index template into the primary unnamed outlet. this.render("navtemplate", {outlet: "nav"}); // this renders the navtemplate into the outlet named ''nav''. this.render("main", {outlet: "main"}); // this renders the main template into the outlet named ''main''. }

Espero que esto ayude.


Ember automáticamente asume / combina con IndexRoute, IndexController e IndexView. Esto está en la guía de enrutamiento de brasas

Para conectar rutas anidadas, puedes hacerlo así:

App.OtherRoute = Ember.Route.extend({ renderTemplate: function() { this.render(''otherTemplate'', { into: ''index'', outlet: ''nav'' }); } });

Aquí hay una respuesta más profunda de otra pregunta.