Forked from jenweber/components.a-teeny-component.js
Last active
October 26, 2018 15:09
-
-
Save NullVoxPopuli/9cf5ca01a0758beaf6e9394f0bffecfa to your computer and use it in GitHub Desktop.
Example of passing actions from controller to nested component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
// this component only received args from the caller | |
// but it does track its own local info property | |
info: '', // initial form field value | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import { computed } from '@ember/object'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
info: '', | |
aComplexInfo: { | |
nestedData: '' | |
}, | |
dataDisplay: computed('aComplexInfo.nestedData', function() { | |
return JSON.stringify(this.aComplexInfo); | |
}), | |
actions: { | |
sendTheForm(info) { | |
console.log('sendTheForm received', info); | |
this.set('info', info); | |
}, | |
updateNestedData(nestedData) { | |
console.log('updateNestedData received', nestedData); | |
this.set('aComplexInfo.nestedData', nestedData); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export function stringify(params/*, hash*/) { | |
return JSON.stringify(params[0]); | |
} | |
export default Ember.Helper.helper(stringify); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
// this component only receives args from the caller | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
text: '' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.border { | |
border: 1px solid; | |
padding: 10px; | |
} | |
span { | |
display: block; | |
padding-bottom: 10px; | |
} | |
input[type='text'] { | |
width: 100%; | |
} | |
button { | |
margin-top: 5px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": true, | |
"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