0

How do I configure Ninject so it injects an instance in a view model?

PS. It is an abstracted service to help with validation, so I am not trying to burden the model with too much responsibilities.

Boris Yankov
  • 3,573
  • 1
  • 23
  • 29

1 Answers1

1

Refer to this SO question - https://stackoverflow.com/questions/8176654/di-ninject-working-for-controllers-but-not-view-model, which points to this link - http://bradwilson.typepad.com/blog/2010/10/service-location-pt5-idependencyresolver.html.

I also had the same issue. For that I extended my NinjectControllerFactory class to provide me with an instance of the required dependency. I blogged about this here - http://blog.thekfactor.info/posts/dependency-injection/.

I may have to look in to the link from the SO post too and see if that's a better alternative.

k25
  • 833
  • 9
  • 13