Skip to content

Instantly share code, notes, and snippets.

@phillipkregg
Last active July 18, 2016 18:52
Show Gist options
  • Save phillipkregg/70509921bba52306ee4515f91bcafe61 to your computer and use it in GitHub Desktop.
Save phillipkregg/70509921bba52306ee4515f91bcafe61 to your computer and use it in GitHub Desktop.
What does application mean
import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('animals');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
// Here is the 'activate' method that fires whenever the route
// is initialized
activate: function() {
$.notify('From the animals route!');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
// Since this model is returned on the application route,
// It will be available on EVERY route that you hit.
// If you move this out and put it into the "animals" route
// then it will only be available on the /animals url
model: function() {
return ['Tiger', 'Zebra', 'Dolphin', 'Unicorn']
},
// Here is the 'activate' method that fires whenever the route
// is initialized
activate: function() {
$.notify('From the application route');
}
});
import Ember from 'ember';
export default Ember.Route.extend({
// Here is the 'activate' method that fires whenever the route
// is initialized
activate: function() {
$.notify('From the index route!');
}
});
@import url(https://fonts.googleapis.com/css?family=Fira+Sans);
body {
margin: 12px 16px;
font-family: 'Fira Sans', Arial, sans-serif;
font-size: 12pt;
}
a {
display: inline-block;
background: white;
text-decoration: none;
padding: 5px 10px;
}
.application-template {
padding: 10px;
background: #2A4173;
color: white;
}
.index-template {
background: #F3E2B4;
color: #000;
padding: 10px;
}
.animal-list-component {
padding: 10px;
color: white;
background: #4F7158;
overflow: auto;
}
.animals-template {
padding: 10px;
color: black;
background: #F3E2B4;
}
.animal-box {
background: #06405C;
color: white;
padding: 10px;
float: left;
margin: 10px;
}
<div class="animals-template">
<h3>Here are the animals:</h3>
<h4>This is the animals.hbs file that loads with the animals route</h4>
<p>We are no longer on the index route, so nothing from index.hbs lives here...</p>
<p>But everything on application.hbs does since it ecompasses everything at the highest level of the application.</p>
{{animal-list
model=model
}}
</div>
<div class="application-template">
<p>This is the application.hbs template</p>
<p>Anything on the application template will be seen everywhere throughout the app... like the navigation below.</p>
<br>
<br>
{{#link-to 'index'}}Home{{/link-to}}
{{#link-to 'animals'}}Animal List{{/link-to}}
{{outlet}}
<br>
<br>
</div>
<div class="animal-list-component">
{{yield}}
<h4>Everything in this box belongs to the animal-list-component</h4>
{{#each model as |animal|}}
<div class="animal-box">
{{animal}}
</div>
{{/each}}
</div>
<div class="index-template">
<p>This is the index.hbs file. It's loaded into the application template with the index route.</p>
</div>
{
"version": "0.10.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.6.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0",
"notify": "https://cdnjs.cloudflare.com/ajax/libs/notify/0.4.2/notify.js"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment