Skip to content

Instantly share code, notes, and snippets.

@jelhan
jelhan / controllers.application\.js
Created October 4, 2022 13:15
No need to explictily set current query param value
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
queryParams = ['foo', 'bar'];
}
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { cached } from 'tracked-toolbox';
import { scheduleOnce } from '@ember/runloop';
const Observers = [];
class Observer {
tags = [];
cb = null;
@jelhan
jelhan / controllers.application\.js
Created November 15, 2021 13:19
Regular link vs LinkTo
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
@jelhan
jelhan / components.my-component\.js
Created March 7, 2021 09:48
StackOverflow fn template helper
import Component from '@glimmer/component';
import { action } from '@ember/object';
export default class extends Component {
animals = ["dog", "cat"];
@action
updateAnimal(animal, event) {
const { value } = event.target;
window.alert(`Changed text for animal ${animal} to ${value}`);
@jelhan
jelhan / controllers.application\.js
Created March 4, 2021 09:49
willTransition order
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
@jelhan
jelhan / controllers.application\.js
Last active December 11, 2020 12:01
ember-data with different attribute naming styles
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
@service intl;
@action changeLocaleToGerman() {
this.intl.locale = 'de-DE';
}
@jelhan
jelhan / models.article\.js
Created September 7, 2020 09:39
Executing methods on Ember Data modls in template
import Model, { attr } from '@ember-data/model';
export default class extends Model {
@attr('string')
title;
@attr('string')
body;
}
@jelhan
jelhan / controllers.application\.js
Created August 5, 2020 18:25
scroll on activate
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
@jelhan
jelhan / controllers.application\.js
Last active August 3, 2020 09:52
ember sets value as a property
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
class MyCustomElement extends HTMLElement {
connectedCallback() {
console.log('connectedCallback of custom element');
console.log('this.hasAttribute("foo")', this.hasAttribute('foo'));
console.log('this.getAttribute("foo")', this.getAttribute('foo'));
}
@jelhan
jelhan / controllers.application\.js
Created July 29, 2020 15:35
Ember Bootstrap Tooltip Blueprint
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}