How to inject ItemViewModel in tornadoFx

323 views Asked by At

I am trying to add model to view by injection

val model = PersonModel by inject()

but error:

'PersonModel' does not have a companion object.

What am i doing wrong ?

1

There are 1 answers

0
Ruckus T-Boom On BEST ANSWER

You need to use :, not =.

val model: PersonModel by inject()

The reason for the error is that, when the compiler sees val model = PersonModel, it assumes you're trying to assign the companion object of the PersonModel class to model, but there isn't one, so it gives you the most helpful message it can, not realizing you made a simple syntax mistake.