Can anyone help me understand how this code flows and how it will be rendered? It is not functioning well on my side and I am not able to understand the code flow.
app/templates/rentals.hbs
<div class="jumbo">
<div class="right tomster"></div>
<h2>Welcome!</h2>
<p>We hope you find exactly what you're looking for in a place to stay.</p>
{{#link-to "about" class="button"}}
About Us
{{/link-to}}
</div>
{{#list-filter filter=(action 'filterByCity') as |filteredResults|}}
<ul class="results">
{{#each filteredResults as |rentalUnit|}}
<li>{{rental-listing rental=rentalUnit}}</li>
{{/each}}
</ul>
{{/list-filter}}
app/templates/list-filter.hbs
{{input value=value
key-up=(action 'handleFilterEntry')
class="light"
placeholder="Filter By City"}}
{{yield}}
app/components/list-filter.js
import Component from '@ember/component';
export default Component.extend({
classNames: ['list-filter'],
value: 'Hello',
init() {
this._super(...arguments);
this.get('filter')('').then((results) => this.set('results', results));
},
actions: {
handleFilterEntry() {
let filterInputValue = this.get('value');
let filterAction = this.get('filter');
filterAction(rentals.model).then((filterResults) => this.set('results', filterResults));
},
}
});
app/controllers/rentals.js
import Controller from '@ember/controller';
export default Controller.extend({
actions: {
filterByCity(param) {
if (param !== '') {
return this.model.filter((i, n) => n.city === param)
} else {
return this.model;
}
}
}
});
I am a beginner trying to learn Ember 2.18 for my office work. I am trying to create a website as per the ember guide v2.18