Skip to content

Instantly share code, notes, and snippets.

@NullVoxPopuli
Last active November 29, 2023 09:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NullVoxPopuli/6e023f1413fbce6bab8954f3eec73554 to your computer and use it in GitHub Desktop.
Save NullVoxPopuli/6e023f1413fbce6bab8954f3eec73554 to your computer and use it in GitHub Desktop.
didInsertElement Example
import Component from '@ember/component';
export default class ItemComponent extends Component {
didInsertElement() {
console.log(`item ${this.item} was inserted`);
}
}
import Component from '@ember/component';
export default class ItemList extends Component {
didInsertElement() {
console.log('list was inserted');
}
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
items = [
1,
2,
3,
4,
5,
]
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{!--
or {{item-list items=this.items}}
if not using angle-bracket invocation
--}}
<ItemList @items={{this.items}} />
<br>
<br>
<hr>
{{!--
or {{item}}
if not using angle-bracket invocation
--}}
{{@item}}
<hr>
{{!--
or {{#each items as |item|}}
if not using angle-bracket invocation
--}}
{{#each @items as |item|}}
{{!--
or {{item-component item=item}}
if not using angle-bracket invocation
--}}
<ItemComponent @item={{item}} />
{{/each}}
{
"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