I have to create shared partial view Partial1 and it will be used on other screens.
So instead of creating specific model PartialModel1 for shared component I can create interface IPartialModel1.
Then other screens could implement IPartialModel1
like
BigScreenModel1:IPartialModel1
BigScreenModel2:IPartialModel1
so in BigScreen.cshtml I can use
@Html.Partial("Partial",BigScreenModel1)
and on BigScreen2.cshtml
@Html.Partial("Partial",BigScreenModel2)
Is this good practice ?
The issue I have with this approach, whilst it will work, is that you are tying the view model of your partial to that of the encompassing page.
A better approach would be to have the partial view model as a member of the pages view model, like the following:
And then of course:
On both pages. This decouples the view models from one another.