UrlSerializer

Stable Class What it does Serializes and deserializes a URL string into a URL tree. Class Overview class UrlSerializer { parse(url: string) : UrlTree serialize(tree: UrlTree) : string } Class Description The url serialization strategy is customizable. You can make all URLs case insensitive by providing a custom UrlSerializer. See DefaultUrlSerializer for an example of a URL serializer. Class Details parse(url: string) : UrlTree Parse a url into a UrlTree. serialize(tree: UrlTree)

UrlSegment

Stable Class What it does Represents a single URL segment. How to use @Component({templateUrl:'template.html'}) class MyComponent { constructor(router: Router) { const tree: UrlTree = router.parseUrl('/team;id=33'); const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET]; const s: UrlSegment[] = g.segments; s[0].path; // returns 'team' s[0].parameters; // returns {id: 33} } } Class Overview class UrlSegment { constructor(path: string, parameters: {[key: s

Validators

Stable Class Class Overview class Validators { staticrequired(control: AbstractControl) : {[key: string]: boolean} staticminLength(minLength: number) : ValidatorFn staticmaxLength(maxLength: number) : ValidatorFn staticpattern(pattern: string) : ValidatorFn staticnullValidator(c: AbstractControl) : {[key: string]: boolean} staticcompose(validators: ValidatorFn[]) : ValidatorFn staticcomposeAsync(validators: AsyncValidatorFn[]) : AsyncValidatorFn } Class Description Provides a

ValueProvider

Stable Interface What it does Configures the Injector to return a value for a token. How to use const provider: ValueProvider = {provide: 'someToken', useValue: 'someValue'}; Interface Overview interface ValueProvider { provide : any useValue : any multi : boolean } Interface Description For more details, see the Dependency Injection Guide. Example const injector = ReflectiveInjector.resolveAndCreate([{provide: String, useValue: 'Hello'}]); expect(injector.get(String)).toEq

UrlTree

Stable Interface What it does Represents the parsed URL. How to use @Component({templateUrl:'template.html'}) class MyComponent { constructor(router: Router) { const tree: UrlTree = router.parseUrl('/team/33/(user/victor//support:help)?debug=true#fragment'); const f = tree.fragment; // return 'fragment' const q = tree.queryParams; // returns {debug: 'true'} const g: UrlSegmentGroup = tree.root.children[PRIMARY_OUTLET]; const s: UrlSegment[] = g.segments; // returns 2

Upgrading from 1.x

Angular 1 applications can be incrementally upgraded to Angular 2. This guide is still in the process of being updated to RC5 and it's samples may not work correctly. Having an existing Angular 1 application doesn't mean that we can't begin enjoying everything Angular 2 has to offer. That's because Angular 2 comes with built-in tools for migrating Angular 1 projects over to the Angular 2 platform. Some applications will be easier to upgrade than others, and there are ways in which we can make

UpperCasePipe

Stable Pipe What it does Transforms string to uppercase. How to use expression | uppercase NgModuleCommonModule Description Converts value into lowercase string using String.prototype.toUpperCase(). Example @Component({ selector: 'lowerupper-pipe', template: `<div> <label>Name: </label><input #name (keyup)="change(name.value)" type="text"> <p>In lowercase: <pre>'{{value | lowercase}}'</pre> <p>In uppercase: <pre>'{{v

URLSearchParams

Experimental Class Class Overview class URLSearchParams { constructor(rawParams?: string, queryEncoder?: QueryEncoder) paramsMap : Map<string, string[]> rawParams : string clone() : URLSearchParams has(param: string) : boolean get(param: string) : string getAll(param: string) : string[] set(param: string, val: string) setAll(searchParams: URLSearchParams) append(param: string, val: string) : void appendAll(searchParams: URLSearchParams) replaceAll(searchPa

TypeScript to JavaScript

Convert Angular 2 TypeScript examples into ES5 JavaScript Everything that we can do in Angular 2 in TypeScript, we can also do in JavaScript. Translating from one language to the other is mostly a matter of changing the way we organize our code and the way we access Angular 2 APIs. Since TypeScript is a popular language option in Angular 2, many of the code examples you see on the Internet as well as on this site are written in TypeScript. This cookbook contains recipes for translating these ki

upgrade

Module Entry point for all public APIs of the upgrade package. UpgradeAdapter UpgradeAdapterRef defined in @angular/upgrade/index.ts