11th Oct 2021
Learning Ember.js
- The
ember new
command is used to start a new project before that you need to have installed the ember cli globally - The cli will help you download and setup all the starter files you need for your project which is neat π
- The
app
folder is where you will be writing most of your code. Static files like fonts and images go in the public
folder - Pages in ember.js are created in the
app/templates
directory with a .hbs
extension. You can write normal html - After createing your page. You should add it to
app/router.js
by mapping through the router class.
Below is an example of how to add a page called about
. make sure to use the same name when creating your .hbs
template.
Router.map(function () {
this.route('about');
this.route('contact', { path: '/getting-in-touch' });
});
- Should you wish to give your page a different route from its file name then you can add an object as a second parameter with
path
set to your desired name. - Ember also has a
LinkTo
component used for client-side navigation.
<LinkTo @route="about">About</LinkTo>