Skip to content

Instantly share code, notes, and snippets.

@thoov
Created May 8, 2018 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoov/c40685d5563cae4cfd360810f572fe43 to your computer and use it in GitHub Desktop.
Save thoov/c40685d5563cae4cfd360810f572fe43 to your computer and use it in GitHub Desktop.
Thought exercise on "Ember Controllerless"
<p>{{data.firstName}}</p>
<p>{{data.lastName}}</p>
{{some-component data}}
<button {{action 'someAction' data.username}}>Trigger someAction</button>
import Route from '@ember/routing/route';
import { action } from '@ember-decorators/object';
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