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
  • 630,263
  • 148
  • 957
  • 1,375
Mouad Ennaciri
  • 1,217
  • 3
  • 15
  • 28

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
  • 630,263
  • 148
  • 957
  • 1,375