Last post Jun 06, 2018 10:06 AM by 1jus
Jun 06, 2018 09:25 AM|1jus|LINK
Hi guys, in the past we have used partial views to render sales data into its parent view. The partial was passed the id of the user and then it went off and got some data to render. With Asp Core View Components this doesn't seem to be an option, as I understand
it the VC can only work with the params passed to it and nothing more, is this the case?
Is there a better option for achieving this other than a View Component?
Jun 06, 2018 10:06 AM|1jus|LINK
Found the answer guys:
Like controllers, view components also take part in dependency injection so any other information you need can simply be injected to the view component. In the example above, we injected the IArticleService that allowed
us to access articles form some remote source. Anything that you could inject into a controller can also be injected into a view component.