Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4830

How do you set default value for component argument when you use es2015 class syntax?

$
0
0

@nightire wrote:

It is common to give a default value for a component argument, then allow users to pass a new value to overwrite it, but it doesn’t work as it should be if you use es2015 syntax.

For example

export default class FooBar extends Component {
  name = 'default';
}
{{foo-bar}}  {{!-- name is "default" --}}
{{foo-bar name="nightire"}} {{!-- name is still "default"}}

there is a workaround:

export default class FooBar extends Component.extend({
  name: 'default'
}) {

}
{{foo-bar}}  {{!-- name is "default" --}}
{{foo-bar name="nightire"}} {{!-- name is "nightire" now}}

but I’m wondering why? and is there a better solution exists?

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4830

Trending Articles