本文整理汇总了TypeScript中angular2/src/core/di/provider.provide函数的典型用法代码示例。如果您正苦于以下问题:TypeScript provide函数的具体用法?TypeScript provide怎么用?TypeScript provide使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了provide函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEachProviders
beforeEachProviders(() => {
return [
HTTP_PROVIDERS,
provide(XHRBackend, {useClass: MockBackend}),
provide(BlogService, {useClass: MockBlogService}),
provide(MarkdownService, {useClass: MockMarkdownService}),
provide(Router, {useClass: MockRouter})
]
});
示例2: beforeEachProviders
beforeEachProviders(() => [
ROUTER_PROVIDERS,
provide(Location, {useClass: SpyLocation}),
provide(Router, {useClass: RootRouter}),
provide(RouteParams, { useValue: new RouteParams({ id: '2' }) }),
provide(APP_BASE_HREF, {useValue: '/'}),
provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppComponent}),
provide(ApplicationRef, {useClass: MockApplicationRef}),
provide(EmployeeService, {useClass: EmployeeService}),
provide(EmployeeEditComponent, {useClass: EmployeeEditComponent})
]);
示例3: injectAsync
injectAsync([TestComponentBuilder], (tcb) => {
return tcb
.overrideProviders(BlogRoll, [provide(BlogService, {useValue: mockBlogService})])
.createAsync(BlogRoll)
.then((fixture) => {
let nativeElement = fixture.nativeElement;
fixture.detectChanges();
nativeElement.querySelector('i.glyphicon-edit').click();
fixture.detectChanges();
expect(fixture.componentInstance.editing).toBe(true);
let blog = fixture.componentInstance.blog;
expect(blog).toBeDefined();
expect(blog.id).toBeDefined();
});
}));
示例4: it
it('shows list of blog items by default', injectAsync([TestComponentBuilder], (tcb) => {
return tcb
.overrideProviders(BlogRoll, [provide(BlogService, {useValue: mockBlogService})])
.createAsync(BlogRoll)
.then((fixture) => {
let nativeElement = fixture.nativeElement;
fixture.detectChanges();
// we start with the blog roll panel visible
expect(fixture.componentInstance.editing).toBe(false);
expect(nativeElement.querySelector('#blog-editor-panel') === null).toBe(true);
expect(nativeElement.querySelector('#blog-roll-panel') === null).toBe(false);
let trs = nativeElement.querySelectorAll('tr');
expect(trs.length).toBe(2);
let tdTitleContent = trs[1].children[1].innerHTML;
let tdRenderedContent = trs[1].children[2].innerHTML;
expect(tdTitleContent).toContain('The title');
expect(tdRenderedContent).toContain('Hi there');
});
}));