angular 10 how to inject a service to a class code example

Example 1: angular how to use service in class

import { <service name>Service } from '../<service path>';
you can inject service in components constructor:
constructor(public anyService: Service){}

Example 2: angular injector.create example

using Angular Injector
Internal class in @angular/core, StaticInjector, ReflectiveInjector 
uses resolveAndCreate([ClassNames])
the resolve variable from above resolver.get(ClassName) will give the object.
All this is handled internally when we inform the angular with the providers