本文整理汇总了TypeScript中@angular/core.ReflectiveInjector类的典型用法代码示例。如果您正苦于以下问题:TypeScript ReflectiveInjector类的具体用法?TypeScript ReflectiveInjector怎么用?TypeScript ReflectiveInjector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReflectiveInjector类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
/**
* Helper methods to add ComponentClass(like modal backdrop) with options
* of type ComponentOptionsClass to element next to application root
* or next to provided instance of view container
* @param ComponentClass - @Component class
* @param ComponentOptionsClass - options class
* @param options - instance of options
* @param contextInjector - injector to resolve root view container (any injector except root injector will fit)
* @returns {ComponentRef<T>} - returns ComponentRef<T>
*/
public appendNextToRoot<T>(ComponentClass:Type<T>,
ComponentOptionsClass:any,
options:any,
contextInjector:Injector):ComponentRef<T> {
let location = this.getRootViewContainerRef(contextInjector);
let providers = ReflectiveInjector.resolve([
{provide: ComponentOptionsClass, useValue: options}
]);
return this.appendNextToLocation(ComponentClass, location, providers);
}
示例2: beforeEach
beforeEach(function() {
routeSet$ = new Subject<Match>();
spyOn(router, 'replace');
spyOn(observer, 'next');
const injector = ReflectiveInjector.resolveAndCreate([
provide(Router, { useValue: router })
]);
redirect = injector.resolveAndInstantiate(RedirectHook);
});
示例3: beforeEach
beforeEach(function() {
routerInstruction$ = new Subject<Match>();
const injector = ReflectiveInjector.resolveAndCreate([
PARAMS_PROVIDERS,
provide(RouterInstruction, { useValue: routerInstruction$ })
]);
routeParams$ = injector.get(RouteParams);
queryParams$ = injector.get(QueryParams);
});
示例4: beforeEach
beforeEach(function () {
const injector = ReflectiveInjector.resolveAndCreate([
ShopEffects,
MOCK_EFFECTS_PROVIDERS,
// Mock out other dependencies (like Http) here
]);
shop = injector.get(ShopEffects);
updates$ = injector.get(MockStateUpdates);
});
示例5: useInjectors
useInjectors(): void {
let injector: any = ReflectiveInjector.resolveAndCreate([
ViewPortService,
provide('OtherSizeService', {useFactory: (viewport: any) => {
return viewport.determineService();
}, deps: [ViewPortService]})
]);
let sizeService: any = injector.get('OtherSizeService');
sizeService.run();
}
示例6: it
it('should infer type', () => {
// #docregion InjectionToken
const BASE_URL = new InjectionToken<string>('BaseUrl');
const injector =
ReflectiveInjector.resolveAndCreate([{provide: BASE_URL, useValue: 'http://localhost'}]);
const url = injector.get(BASE_URL);
// here `url` is inferred to be `string` because `BASE_URL` is `InjectionToken<string>`.
expect(url).toBe('http://localhost');
// #enddocregion
});
示例7: beforeEach
beforeEach(() => {
var injector = ReflectiveInjector.resolveAndCreate(
[{provide: ResponseOptions, useClass: BaseResponseOptions}, MockBackend]);
backend = injector.get(MockBackend);
var base = new BaseRequestOptions();
sampleRequest1 = new Request(base.merge(new RequestOptions({url: 'https://google.com'})));
sampleResponse1 = new Response(new ResponseOptions({body: 'response1'}));
sampleRequest2 = new Request(base.merge(new RequestOptions({url: 'https://google.com'})));
sampleResponse2 = new Response(new ResponseOptions({body: 'response2'}));
});
示例8: beforeEach
beforeEach(() => {
let injector = ReflectiveInjector.resolveAndCreate([
ROUTER_FAKE_PROVIDERS,
// Angulartics2 relies on router for virtual page view tracking
Angulartics2, Angulartics2Segment, AnalyticsService
]);
analyticsService = injector.get(AnalyticsService);
analyticsService.devMode(false);
segment = injector.get(Angulartics2Segment);
});
示例9: beforeEach
beforeEach(() => {
onerrorSpy = jasmine.createSpy('onerror');
superHandler = spyOn(ErrorHandler.prototype, 'handleError');
const injector = ReflectiveInjector.resolveAndCreate([
{ provide: ErrorHandler, useClass: ReportingErrorHandler },
{ provide: WindowToken, useFactory: () => ({ onerror: onerrorSpy }) }
]);
handler = injector.get(ErrorHandler);
});
示例10: createInjector
function createInjector(initialUrl: string) {
return ReflectiveInjector.resolveAndCreate([
DocumentService,
{ provide: LocationService, useFactory: () => new MockLocationService(initialUrl) },
{ provide: ConnectionBackend, useClass: MockBackend },
{ provide: RequestOptions, useClass: BaseRequestOptions },
{ provide: Logger, useClass: MockLogger },
Http,
]);
}