Skip to content

Instantly share code, notes, and snippets.

@hjumeau
Created February 26, 2016 15:39
Show Gist options
  • Save hjumeau/50e244cd7778e1961849 to your computer and use it in GitHub Desktop.
Save hjumeau/50e244cd7778e1961849 to your computer and use it in GitHub Desktop.
ComponentLifecycle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('user', {path:'user/:name'});
});
export default Router;
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.error {
color:red;
}
{
"version": "0.6.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.3.1/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js"
}
}
import Ember from 'ember';
export default Ember.Component.extend({
capitalizedName:null,
isCool:false,
didReceiveAttrs(){
this.set('capitalizedName', Ember.String.capitalize(this.get('name')));
},
didInsertElement(){
alert(this.$('.name').text());
},
didUpdateAttrs(){
this.set('isCool', false);
}
});
<span class='name'>{{capitalizedName}}</span>
{{input type="checkbox" checked=isCool}}is cool
import Ember from 'ember';
export default Ember.Route.extend({
model(params){
return params.name;
}
});
{{user-card name=model}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment