Skip to content

Instantly share code, notes, and snippets.

@siva-sundar
Forked from nishanmiranda/application.controller.js
Last active November 4, 2015 13:02
Show Gist options
  • Save siva-sundar/0afe7b5125eef693a8b8 to your computer and use it in GitHub Desktop.
Save siva-sundar/0afe7b5125eef693a8b8 to your computer and use it in GitHub Desktop.
sendAction --- targetObject
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
submit: function() {
alert('controller');
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#foo-line as |value|}}
<p>
<h2>Nested component</h2>
{{foo-bar action=(action value.samp target=value)}}
</p>
{{/foo-line}}
{{foo-line}}
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
submit: 'submit',
//targetObject: Em.computed.alias('parentView'),
actions: {
foo: function() {
console.log('hai');
this.sendAction('action');
}
}
});
<button {{action 'foo'}}>Trigger</button>{{yield}}
import Ember from 'ember';
import mixin from 'demo-app/mixin'
export default Ember.Component.extend({
'samp': 'submit',
actions: {
submit: function() {
alert('component foo');
}
}
});
{{#if hasBlock}}
{{yield this}}
{{else}}
<p>
<h2>Nested component</h2>
{{foo-bar action='submit'}}
</p>
{{/if}}
export default Em.Mixin.create({
actions: {
submit: function() {
alert('component foo');
}
}});
{
"version": "0.4.16",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment