import {TestService1} from '../../../../test1.service';
import {TestService2} from '../../../../test2.service';
import {AbstractclassService} from '../../../../abstractclass.service';
import { InjectionToken } from '@angular/core';
const SERVICE1_or_SERVICE2 = new InjectionToken<string>('AbstractclassService');
@Component({
selector: 'app-gauge',
templateUrl: './gauge.component.html',
providers: [
{
provide: SERVICE1_or_SERVICE2,
useValue: Service1,
multi: true
},
{
provide: SERVICE1_or_SERVICE2,
useValue: Service2,
multi: true
}
],
styleUrls: ['./gauge.component.css']
})
我想使用一个抽象类,其中我注入了TestService1和TestService2来显示我的组件中的一些数据。我怎样才能使用INjectionToken权限来决定每次使用哪种服务?