本文整理汇总了TypeScript中@angular/core.Injector类的典型用法代码示例。如果您正苦于以下问题:TypeScript Injector类的具体用法?TypeScript Injector怎么用?TypeScript Injector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Injector类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(injector: Injector) {
this.defaultCounterId = injector.get<string>(DEFAULT_COUNTER_ID);
this.counterConfigs = injector.get<YandexCounterConfig[]>(YANDEX_COUNTERS_CONFIGS);
this.positionToId = this.counterConfigs.map(config => config.id);
}
开发者ID:FriOne,项目名称:ng-yandex-metrika,代码行数:5,代码来源:ng-yandex-metrika.service.ts
示例2: constructor
constructor(service: Service, injector: Injector) {
this.instance1 = service.instance;
this.instance2 = injector.get(Service).instance;
}
开发者ID:BobChao87,项目名称:angular,代码行数:4,代码来源:lib2.ts
示例3: describe
describe('ResourceService', () => {
let injector: Injector;
let resourceService: ResourceService;
let httpMock: HttpTestingController;
beforeEach(() => {
injector = TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [
ResourceService
]
});
resourceService = injector.get(ResourceService);
httpMock = injector.get(HttpTestingController);
});
afterEach(() => httpMock.verify());
it('should make a single connection to the server', () => {
const req = httpMock.expectOne({});
expect(req.request.url).toBe('generated/resources.json');
});
describe('#categories', () => {
let categories: Category[];
let testData: any;
beforeEach(() => {
testData = getTestResources();
httpMock.expectOne({}).flush(testData);
resourceService.categories.subscribe(results => categories = results);
});
it('categories observable should complete', () => {
let completed = false;
resourceService.categories.subscribe(null, null, () => completed = true);
expect(true).toBe(true, 'observable completed');
});
it('should reshape contributors.json to sorted category array', () => {
const actualIds = categories.map(c => c.id).join(',');
expect(actualIds).toBe('cat-1,cat-3');
});
it('should convert ids to canonical form', () => {
// canonical form is lowercase with dashes for spaces
const cat = categories[1];
const sub = cat.subCategories[0];
const res = sub.resources[0];
expect(cat.id).toBe('cat-3', 'category id');
expect(sub.id).toBe('cat3-subcat2', 'subcat id');
expect(res.id).toBe('cat3-subcat2-res1', 'resources id');
});
it('resource knows its category and sub-category titles', () => {
const cat = categories[1];
const sub = cat.subCategories[0];
const res = sub.resources[0];
expect(res.category).toBe(cat.title, 'category title');
expect(res.subCategory).toBe(sub.title, 'subcategory title');
});
it('should have expected SubCategories of "Cat 3"', () => {
const actualIds = categories[1].subCategories.map(s => s.id).join(',');
expect(actualIds).toBe('cat3-subcat2,cat3-subcat1');
});
it('should have expected sorted resources of "Cat 1:SubCat1"', () => {
const actualIds = categories[0].subCategories[0].resources.map(r => r.id).join(',');
expect(actualIds).toBe('a-a-a,s-s-s,z-z-z');
});
});
it('should do WHAT(?) if the request fails');
});
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:79,代码来源:resource.service.spec.ts
示例4: function
function(injector: Injector) {
runBlockTriggered = true;
expect(injector.get($INJECTOR)).toBeDefined();
}
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:4,代码来源:injection_spec.ts
示例5: beforeEach
beforeEach(inject([ Injector ], (injector: Injector) => {
audioContext = injector.get<IAudioContext>(AudioContext);
isSupported = injector.get<() => Promise<boolean>>(audioContextModuleIsSupported);
}));
开发者ID:chrisguttandin,项目名称:angular-audio-context,代码行数:4,代码来源:module.ts
示例6: constructor
constructor(protected injector: Injector) {
this.config = this.injector.get(AppConfig).getConfiguration();
}
开发者ID:gatsbimantico,项目名称:ontimize-web-ngx,代码行数:3,代码来源:auth-guard.provider.ts
示例7:
appRef.registerBootstrapListener(() => { injector.get(Router).initialNavigation(); });
开发者ID:FionaWong,项目名称:angular,代码行数:1,代码来源:router_app_module.ts
示例8: it
it('merges imports and exports', () => { expect(injector.get(AOT_TOKEN)).toEqual('exports'); });
开发者ID:cyrilletuzi,项目名称:angular,代码行数:1,代码来源:module_spec.ts
示例9: beforeEach
beforeEach(() => {
locationService = injector.get(LocationService) as any as MockLocationService;
navService.currentNodes.subscribe(selected => currentNodes = selected);
httpMock.expectOne({}).flush(navJson);
});
开发者ID:DallanQ,项目名称:rxjs,代码行数:5,代码来源:navigation.service.spec.ts
示例10: return
return () => {
let zone = injector.get(NgZone);
zone.runGuarded(() => injector.get(MessageBasedPlatformLocation).start());
};
开发者ID:Brantner,项目名称:angular,代码行数:5,代码来源:location_providers.ts
注:本文中的@angular/core.Injector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论