ember serve
ember build
ember test
ember generate model user
npm install bower -g
npm install ember-cli -g
ember new my-app
Easy to use - for programmers and designers!
"HTML+"
{{myTitle}}
{{#each myArray as |item|}}
- {{item}}
{{/each}}
{{#if isActive}}
This is active!
{{else}}
This is inactive...
{{/if}}
// app/pods/users/controller.js
import Ember from "ember";
export default Ember.Controller.extend({
users: ["John", "Anna", "Max"]
});
// app/pods/users/template.hbs
All Users
{{#each users as |user|}}
{{user}}
{{/each}}
Components should be designed to be reusable. Ember want you to use as many components as possible!
All Users
{{#each users as |user|}}
{{my-user-component userName=user}}
{{/each}}
// app/pods/components/my-user-component/component.js
import Ember from "ember";
export default Ember.Component.extend({
isAdmin: Ember.computed("attrs.userName", function() {
return this.getAttr("userName") === "John";
})
});
// app/pods/components/my-user-component/template.hbs
{{userName}}{{#if isAdmin}} - Admin User{{/if}}
$.ajax()
calls.
// app/pods/user/model.js
import DS from "ember-data";
export DS.Model.extend({
name: DS.attr("string"),
age: DS.attr("number")
});
// app/pods/user/controller.js
var user = this.store.createRecord("user");
user.set("name", "John");
user.save();
Ember-CLI provides hooks, which makes it possible to have a unified API for addons.
ember install ember-cli-sass
ember install ember-cli-autoprefixer
... there is a lot to learn about Ember, and the beginning can seem daunting.
This presentation:
http://mydea.github.io/ember-presentation/