Skip to content

Instantly share code, notes, and snippets.

@michalsnik
Forked from jbandura/application.controller.js
Last active December 19, 2018 07:57
Show Gist options
  • Save michalsnik/f553dfdb3ad17c7bbc32d78f1a7a4d60 to your computer and use it in GitHub Desktop.
Save michalsnik/f553dfdb3ad17c7bbc32d78f1a7a4d60 to your computer and use it in GitHub Desktop.
ember-rekru
import Controller from '@ember/controller';
export default Controller.extend({
user: {
fullName: 'Emma Watson',
},
});
import Route from '@ember/routing/route';
export default Route.extend({
});
<h3>EmberFest:</h3>
{{signup-component}}
<h3>EmberCamp:</h3>
{{signup-component}}
<hr>
<p>
<b>Controller</b><br>
User name: {{user.fullName}}
</p>
<p>
<b>Component</b>
{{two-way user=user}}
</p>
import Component from '@ember/component';
import { observer, get, set } from '@ember/object';
export default Component.extend({
members: [],
currentMember: null,
membersAmount: 0,
onAddedMembers: observer('members.[]', function() {
set(this, 'membersAmount', get(this, 'members.length'));
}),
actions: {
addMember(member) {
get(this, 'members').pushObject(get(this, 'currentMember'));
set(this, 'currentMember', null);
},
deleteMember(member) {
get(this, 'members').removeObject(member);
}
}
});
<div>
Sign up:
{{input type="text" value=currentMember}}
<button {{action "addMember"}}>Add</button>
</div>
<ul>
{{#each members as |member|}}
<li>
{{member}}
<button {{action "deleteMember" member}}>Delete</button>
</li>
{{/each}}
</ul>
<p>Members Amount: {{membersAmount}}</p>
import Component from '@ember/component';
import { alias } from '@ember/object/computed';
export default Component.extend({
userName: alias('user.fullName'),
});
{{input value=userName}}<br>
User name: {{userName}}
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment