<How should I instantiate a ViewModel in a Fragmen...
# stackoverflow
u
How should I instantiate a ViewModel in a Fragment? It works fine in an activity I have a working code while it's placed on an activity. But when I want to use the same code in a fragment, it's not working. I guess instantiation of the ViewModel in a Fragment takes in different arguments. I'd appreciate your input. Thanks Here's the instantiation in the activity, but not working in Fragment. private val hymnViewModel: HymnViewModel by viewModels { HymnViewModelFactory((application as HymnsApplication).repository) } View Model: class HymnViewModel(private val...