Skip to content

Instantly share code, notes, and snippets.

@thoov
Last active May 8, 2018 15:50
Show Gist options
  • Save thoov/985e5689058bee791874e88c16899c00 to your computer and use it in GitHub Desktop.
Save thoov/985e5689058bee791874e88c16899c00 to your computer and use it in GitHub Desktop.
Thought exercise on "Ember Controllerless"
<p>{{data.firstName}}</p>
<p>{{data.lastName}}</p>
{{some-component user=data}}
<button {{action 'someAction' data.username}}>Trigger someAction</button>
import Route from '@ember/routing/route';
import { action } from '@ember-decorators/object';
import { model } from '@ember-decorators/model';
export Class extends Route {
@service queryParams
@model
data() {
const { sort } = this.queryParams.forRoute(this)
// Anything returned from here would be accessible on the
// template via `data`
return fetch(`/v1/data?sort=${sort}`).then(res => res.json());
}
willEnter() {}
didEnter() {}
willLeave() {}
didLeave() {}
@action
someAction() {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment