Previously, I was able to provide default values to arguments like this:
component.js:
Component.extend({
foo: 'bar'
})
template.hbs:
{{foo}}
result:
bar
It was a simple, efficient and very declarative way of specifying default values. It both worked well and was obvious to developers reading the code.
With named args, this no longer works. Though an argument passed externally does overwrite this.foo, setting an initial value to this.foo does not affect @foo in the template.
As a result, there is no way of specifying a default values for arguments!
The only workaround I'm aware of is to keep using {{foo}} or {{this.foo}} instead of {{@foo}}. This works, but it defeats the purpose of @-named args in templates.
Thus, we need a simple, declarative way of specifying default values for arguments used in components.
A developer should be able to tell which arguments are gonna have which default values by simply looking at the component JS file. Those definitions should not be obscured inside a hook such as init.
Previously, I was able to provide default values to arguments like this:
component.js:
template.hbs:
result:
It was a simple, efficient and very declarative way of specifying default values. It both worked well and was obvious to developers reading the code.
With named args, this no longer works. Though an argument passed externally does overwrite
this.foo
, setting an initial value tothis.foo
does not affect@foo
in the template.As a result, there is no way of specifying a default values for arguments!
The only workaround I'm aware of is to keep using
{{foo}}
or{{this.foo}}
instead of{{@foo}}
. This works, but it defeats the purpose of @-named args in templates.Thus, we need a simple, declarative way of specifying default values for arguments used in components.
A developer should be able to tell which arguments are gonna have which default values by simply looking at the component JS file. Those definitions should not be obscured inside a hook such as
init
.