Code Monkey home page Code Monkey logo

ember-routing's People

Contributors

ember-tomster avatar ga-meb avatar jrhorn424 avatar laurenfazah avatar payne-chris-r avatar

Watchers

 avatar  avatar

ember-routing's Issues

Update code example

@raq929 suggests changing the following code example
https://github.com/ga-wdi-boston/ember-routing/tree/solution#routing-with-dynamic-segments

From:

 // app/routes/product.js

import Ember from 'ember';

export default Ember.Route.extend({
  model: function(params){
    return [
      {
        id: 1,
        name: 'Crock Pot',
        manufacturer: 'Farberware',
        price: 40
      },
      {
        id: 2,
        name: 'Food Processor',
        manufacturer: 'Cuisinart',
        price: 25
      },
      {
        id: 3,
        name: 'Electric Griddle',
        manufacturer: 'George Foreman Grills',
        price: 15
      },
    ][params.product_id - 1];
  }
});

To:

import Ember from 'ember';

export default Ember.Route.extend({
  model(params) {
    const id = params.product_id;

    const products = [
    {
      id: 1,
      name: 'Crock Pot',
      manufacturer: 'Farberware',
      price: 40,
    },
    {
      id: 2,
      name: 'Food Processor',
      manufacturer: 'Cuisinart',
      price: 25,
    },
    {
      id: 3,
      name: 'Electric Griddle',
      manufacturer: 'George Foreman Grills',
      price: 15,
    },
   ];
    return products.find((product) => product.id === +id);
  },
});

The diff:

import Ember from 'ember';

export default Ember.Route.extend({
  model(params) {
    const id = params.product_id;

    const products = [
    {
      id: 1,
      name: 'Crock Pot',
      manufacturer: 'Farberware',
      price: 40,
    },
    {
      id: 2,
      name: 'Food Processor',
      manufacturer: 'Cuisinart',
      price: 25,
    },
    {
      id: 3,
      name: 'Electric Griddle',
      manufacturer: 'George Foreman Grills',
      price: 15,
    },
-   ][params.product_id - 1];
+   ];
+   return products.find((product) => product.id === +id);
  },
});

reword `create a route object` objective

per @raq929 016 delivery

-   Create new Routes and Templates with generators.
-   Configure the Ember Router to point to a new Template.
-   Use the `{{#link-to}}` helper to route from one view-state to another.
-   Set up resource routes.
-   Create a Route object.
-   Configure a Route to parse information from a URL.

Typo

"in the previous lesson..."
There isn't a previous lesson anymore, we've combined them here.

A visual could help with explaining templates and outlet

This should be re-done so that it is more clear but here is an example of what might be useful either as an example in the README or delivery notes for consultants.

The URLs are in blue.
/team
/team/engineering
/team/leadership

The file names are in red
application.hbs
team.hbs
team/index.hbs
team/engineering.hbs
team/leadership.hbs
image

Always use flags in their most verbose/explicit form

- Let's create one of those new Views and see how it works. Run the command `ember g template` 
+ Let's create one of those new Views and see how it works. Run the command `ember generate template` 
about in the console; it should create a new file, about.hbs, inside the templates directory. Let's write some new HTML into that file:

Explain Ember routes behavior

These are notes from @jrhorn424 that should be added to the ember talks and made into learning objectives. Note: This issue may be closed if it is better suited for another talk.

  • If you have a model named foo, you cannot have a route named foo anywhere in the rendering hierarchy if you want the route's model hook to be activated.
  • Routes with dynamic segments: their hooks are only activated from the URL. This may or may not be related to previous statement.
  • Give in. You want nested routes on the front-end. Remember those rails intuitions you used to have? Nest the fuck out of your routes. parent/:parent_id/child/new should have a new route for each segment nested under the previous. Use outlets liberally. This makes re-using components easier (when you wish) and it makes associating children with parents for joins far easier.
  • Stop saying "nested routes mean nested UI", JEFF! That's only true when you aren't using index routes.

These could be added below https://github.com/ga-wdi-boston/ember-routing#routing-with-dynamic-segments.

Templates should be generated before the routes are created

@raq929 suggests that the templates should be generated before the routes are created to stay consistent.

One example of the route being written first is
https://github.com/MicFin/ember-routing#code-along-nested-templates

Router.map(function() {
  this.route('about');
  this.route('contact');
  this.route('team', function(){
    this.route('engineering');
    this.route('leadership');
  });
});

Next, we need to set up our Templates. The appropriate syntax to use in the generator is ember g template team/something - this will let ember-cli know to create a app/templates/team and a something.hbs file inside that directory.

Please review the other examples as well.

js-standardize

This repo doesn't use standard-js (has ;s) at least in the README. #getitouttttatherethennn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.