Q:

How do I get the reference or instance of a component?

0

This code will help you to understand how to get the reference or instance of a component.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Component references are used to invoke methods from underlying components. Use the ref attribute for a component and define it filed with the same name and same type of component.

@page "/"
  
 <Counter IncrementValue="10" @ref="counter"></Counter>
  
 @code {
  
     private Counter counter;    
  
 } 

While the Counter component is rendered, the field counter is populated along with the component instance.

I would suggest you check the below link for better understanding:

https://docs.microsoft.com/en-in/aspnet/core/blazor/components#capture-references-to-components

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now