Reputation: 1032
It's not entirely clear how to iterate over controller properties in a template. I stumbled on a method:
{{#each-in this as |key value|}}
{{key}}: {{value}}
{{/each-in}}
and that kind of works, but it's outputting some internal functions in addition to the properties:
q: shirt
search_page: 3
_qpDelegate: function (prop, value) { var qp = map[prop]; _this._qpChanged(prop, value, qp); return _this._activeQPChanged(map[prop], value); }
My controller looks like:
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: [
'q',
'search_page'
],
q: 'shirt',
search_page: 3
});
Is there a way to iterate and exclude the functions?
Upvotes: 2
Views: 60
Reputation: 35491
Since it appears you only need to do this for debugging purposes, one possible solution would be to create a custom helper to filter out functions (or whatever else you want):
// helpers/debug-filter.js
export function debugFilter([value]) {
return Ember.typeOf(value) !== 'function';
}
export default Ember.Helper.helper(formatCurrency);
Your controller's template
{{#each-in this as |key value|}}
{{#if (debug-filter value)}}
{{key}}: {{value}}
{{/if}}
{{/each-in}}
Upvotes: 1