I am learning Ember.js by following the tutorial Super Rental (https://guides.emberjs.com/v2.12.0/tutorial/ember-cli/). This repository saves my steps and note.
- Node.js:
brew install node - Ember:
npm install -g ember-cli - Phantom.js:
npm install -g phantomjs - Watchman:
npm install -g watchman
Ember CLI provides several tools to develop Ember application. To create an application: ember new super-rentals
To take a quick look at the initial application, start it with ember serve or ember s for short.
Add acceptance test: ember g acceptance-test list-rentals, where g is short for generate
When we want to make a new page that can be visited using a URL, we need to generate a route.
Running ember g route about does the following
- Add an entry in Ember router (
app/router.js), which maps between route name a specific URL. - Create a route handler file (
app/routes/about.js), which sets up what should happen when that route is loaded. - Create a route template (
app/templates/about.hbs), which defines the actual content of the page. - Create test file
tests/unit/routes/about-test.js
Each route handler has a set of “lifecycle hooks”, which are functions that are invoked at specific times during the loading of a page.
Ember keeps data for a page in an object called a model.
Running ember g component rental-listing generates a component. A component consists of two parts:
- A template (
app/components/rental-listing.js) that defines how it will look - A JavaScript file (
app/templates/components/rental-listing.hbs) that defines how it will behave.