Why are there in many examples elipsis, or three dots in front of an Angular2 Import.
It doesn't seem to be required, I can remove them and my application will still work. I saw this "pattern" in angular2 examples and in the seed I'm using.
I however would like to understand why this is done, I'm not sure if I'm looking for the wrong phrases because I've tried to look this up multiple times before.
providers: [...FORM_PROVIDERS],
directives: [ ...ROUTER_DIRECTIVES]
seems to be the same as
providers: [FORM_PROVIDERS],
directives: [ROUTER_DIRECTIVES]
Is it just for clarifying these are multiple providers/components?
From my comments above.
What you call ellipsis is the ES2015 spread operator.
Otherwise, FORM_PROVIDERS
, ROUTER_DIRECTIVES
and others are basically arrays of providers, they're just spread in a new array instance. This allows you to pass a flat array of providers if you add multiple of those.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With