Skip to content

Instantly share code, notes, and snippets.

@krisselden
krisselden / blog-post-at-lookup.hbs
Last active Mar 29, 2019 — forked from raycohen/0-Overview.md
`@` as means argument to the template not property
View blog-post-at-lookup.hbs
<div class="blog-post">
<header>
<Avatar class="blog-post__avatar" @user={{@user}} />
<title>{{@title}}</title>
</header>
<p>
{{@body}}
</p>
</div>
View controllers.application.js
import Ember from 'ember';
const { ArrayProxy, set } = Ember;
const CustomArrayProxy = ArrayProxy.extend({
destroy() {
set(this, 'content', []);
this._super(...arguments);
}
});
View controllers.application.js
import Ember from 'ember';
const values = [
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
];
export default Ember.Controller.extend({
sliderIndex: 1,
values: Ember.computed('sliderIndex', function() {
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
length: 6,
originalVal: '',
arrayVal: Ember.computed('originalVal', function() {
const origin = this.get('originalVal').toString();
const len = this.get('length');
let arr = new Array(len);
View controllers.application.js
import Ember from 'ember';
var fib = function(n){
switch(n){
case 0: return 0;
case 1: return 1;
default: return fib(n-1) + fib(n-2);
}
};
View components.yielding-comp.js
import Ember from 'ember';
const { computed } = Ember;
const { readOnly } = computed;
export default Ember.Component.extend({
cost: readOnly('delayedCalculation.cost'),
tax: readOnly('delayedCalculation.tax'),
// One way to clear up the problem is to use the below CP definitions instead of the readOnly macros
// cost: computed('delayedCalculation.cost', function(){
View components.foo-bar.js
import Ember from 'ember';
export default Ember.Component.extend({
tagName: '',
init() {
this.set('tagName', 'div');
this._super();
},
});
View components.my-component.js
import Ember from 'ember';
import f from '../templates/components/foo-bar';
import b from '../templates/components/foo-baz';
export default Ember.Component.extend({
init() {
this._super(...arguments);
if (this.cond) {
this.layout = f;
} else {
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
View gist:4320710
InsightArticleView: Em.ContainerView.extend
tagName: 'article'
childViews: ['toolbar']
toolbar: Core.EditorToolbarView
You can’t perform that action at this time.