TrackByFn

Stable Interface Interface Overview interface TrackByFn { } Interface Description An optional function passed into NgFor that defines how to track items in an iterable (e.g. by index or id) exported from @angular/core/index, defined in @angular/core/src/change_detection/differs/iterable_differs.ts

tick()

Experimental Function Class Export export tick(millis?: number) : void Simulates the asynchronous passage of time for the timers in the fakeAsync zone. The microtasks queue is drained at the very start of this function and after any timer callback has been executed. Example describe('this test', () => { it('looks async but is synchronous', <any>fakeAsync((): void => { var flag = false; setTimeout(() => { flag = true; }, 100); expect(flag).toBe(false);

TestModuleMetadata

Experimental Type-alias Interface Overview interface TestModuleMetadata { } Interface Description exported from @angular/core/testing/index, defined in @angular/core/testing/test_bed.ts

Testing

Techniques and practices for testing an Angular 2 app This chapter offers tips and techniques for testing Angular applications. Along the way you will learn some general testing principles and techniques but the focus is on Angular testing. Contents Introduction to Angular Testing Setup The first karma test The Angular Testing Platform (ATP) The sample application and its tests A simple component test Test a component with a service dependency Test a component with an async service Test a comp

TestBed

Experimental Class Class Overview class TestBed { staticinitTestEnvironment(ngModule: Type<any>, platform: PlatformRef) : TestBed staticresetTestEnvironment() staticresetTestingModule() : typeof TestBed staticconfigureCompiler(config: {providers?: any[]; useJit?: boolean;}) : typeof TestBed staticconfigureTestingModule(moduleDef: TestModuleMetadata) : typeof TestBed staticcompileComponents() : Promise<any> staticoverrideModule(ngModule: Type<any>, override: Me

TestComponentRenderer

Experimental Class Class Overview class TestComponentRenderer { insertRootElement(rootElementId: string) } Class Description An abstract class for inserting the root test component element in a platform independent way. Class Details insertRootElement(rootElementId: string) exported from @angular/core/testing/index, defined in @angular/core/testing/test_bed.ts

Structural Directives

Angular has a powerful template engine that lets us easily manipulate the DOM structure of our elements. One of the defining features of a single page application is its manipulation of the DOM tree. Instead of serving a whole new page every time a user navigates, whole sections of the DOM appear and disappear according to the application state. In this chapter we'll to look at how Angular manipulates the DOM and how we can do it ourselves in our own directives. In this chapter we will learn wh

Testability

Experimental Class Class Overview class Testability { constructor(_ngZone: NgZone) increasePendingRequestCount() : number decreasePendingRequestCount() : number isStable() : boolean whenStable(callback: Function) : void getPendingRequestCount() : number findBindings(using: any, provider: string, exactMatch: boolean) : any[] findProviders(using: any, provider: string, exactMatch: boolean) : any[] } Class Description The Testability service provides testing hooks that c

TestabilityRegistry

Experimental Class Class Overview class TestabilityRegistry { constructor() registerApplication(token: any, testability: Testability) getTestability(elem: any) : Testability getAllTestabilities() : Testability[] getAllRootElements() : any[] findTestabilityInTree(elem: Node, findInAncestors?: boolean) : Testability } Class Description A global registry of Testability instances for specific elements. Annotations @Injectable() Constructor constructor() Class Details re

TemplateRef

Stable Class Class Overview class TemplateRef { C elementRef : ElementRef createEmbeddedView(context: C) : EmbeddedViewRef<C> } Class Description Represents an Embedded Template that can be used to instantiate Embedded Views. You can access a TemplateRef, in two ways. Via a directive placed on a <template> element (or directive prefixed with *) and have the TemplateRef for this Embedded View injected into the constructor of the directive using the TemplateRef Token. Alte