Skip to content

Instantly share code, notes, and snippets.

View phillipkregg's full-sized avatar
💭
Kick it!

Phil Lackey phillipkregg

💭
Kick it!
  • Nashville, TN
View GitHub Profile
import Ember from 'ember';
export default Ember.Component.extend({
property1: undefined,
property2: undefined,
actions: {
coolClick: function() {
this.set('property1', 'Yo');
this.set('property2', 'Sup');
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
goHome: function() {
this.transitionToRoute('index');
},
goToHotels: function() {
import Ember from 'ember';
export default Ember.Component.extend({
myInputValue: '',
actions: {
fromComponent: function() {
var message = this.get('myInputValue');
debugger;
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@phillipkregg
phillipkregg / components.my-component.js
Last active July 11, 2016 02:56
Listening for property changes outside of component
import Ember from 'ember';
export default Ember.Component.extend({
changedElement: Ember.observer('changeTest', function() {
alert('changed');
})
});
@phillipkregg
phillipkregg / components.cart-contents.js
Last active July 13, 2016 13:28
Services - Shopping Cart
import Ember from 'ember';
export default Ember.Component.extend({
// Here is where the injection of the service happens.
// Ember.inject.service takes an argument that is the name of the
// file of the service that you created.
// If your variable name matches the service name, you would not
// need to add the argument at all.
// For example: shopping-cart: Ember.inject.service()
cart: Ember.inject.service('shopping-cart'),
@phillipkregg
phillipkregg / components.application-area.js
Last active July 20, 2016 07:40
Application-Level Component
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement: function() {
// any JS inits that need to happen
// universally can be called here.
//
// For example if you need to register
// bootstrap dropdowns, you can do something
// like $('.dropdown-toggle').dropdown()
@phillipkregg
phillipkregg / components.movie-displayer.js
Last active July 26, 2016 21:56
Component With Service
import Ember from 'ember';
export default Ember.Component.extend({
movieService: Ember.inject.service('movie-displayer-service'),
currentSelectedMovie: '',
didInsertElement: function() {
// When the component is inserted into the DOM tree, use the model to set
// the 'currentSelectedMovie' property.
this.set('currentSelectedMovie', this.get('model').currentSelectedMovie);
import Ember from 'ember';
export default Ember.Component.extend({
movieService: Ember.inject.service('movie-displayer-service'),
actions: {
selectMovie: function(movie) {
// Instead of saving state in the component itself, let's
// save it in a service that can be consumed anywhere
// in the application.
@phillipkregg
phillipkregg / components.restaurant-list.js
Last active July 20, 2016 08:03
Actions Up - Capturing State
import Ember from 'ember';
export default Ember.Component.extend({
currentlySelectedRestaurant: undefined,
actions: {
selectRestaurant: function(restaurant) {
// The 'sendAction' method is where the magic happens.