1

I initialize my component with this constructor :

constructor($q, $state) {
  'ngInject'
  Object.assign(this, { $q, $state })
}

the simple equivalent of

this.$q = $q
this.$state = $state

What is it alternative with Spread operator ?

Bergi
  • 572,313
  • 128
  • 898
  • 1,281
Mouad Ennaciri
  • 1,027
  • 2
  • 11
  • 27

1 Answers1

1

None. You can only use spread syntax when creating a new object with literal syntax. You don't do that when you use a constructor.

Btw, there is no spread "operator", and object spread syntax is not part of ES6.

Bergi
  • 572,313
  • 128
  • 898
  • 1,281