X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions modules/angular2/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export {URLSearchParams} from './src/http/url_search_params';
* search: string = 'coreTeam=true';
* }
*
* bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {asClass: MyOptions})])
* bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})])
* .catch(err => console.error(err));
* ```
*
Expand All @@ -125,7 +125,7 @@ export {URLSearchParams} from './src/http/url_search_params';
* var injector = Injector.resolveAndCreate([
* HTTP_PROVIDERS,
* MockBackend,
* provide(XHRBackend, {asAlias: MockBackend})
* provide(XHRBackend, {useExisting: MockBackend})
* ]);
* var http = injector.get(Http);
* var backend = injector.get(MockBackend);
Expand Down Expand Up @@ -153,12 +153,12 @@ export const HTTP_PROVIDERS: any[] = [
// issue: https://github.com/angular/angular/issues/3183
provide(Http,
{
asFactory: (xhrBackend, requestOptions) => new Http(xhrBackend, requestOptions),
useFactory: (xhrBackend, requestOptions) => new Http(xhrBackend, requestOptions),
deps: [XHRBackend, RequestOptions]
}),
BrowserXhr,
provide(RequestOptions, {asClass: BaseRequestOptions}),
provide(ResponseOptions, {asClass: BaseResponseOptions}),
provide(RequestOptions, {useClass: BaseRequestOptions}),
provide(ResponseOptions, {useClass: BaseResponseOptions}),
XHRBackend
];

Expand Down Expand Up @@ -230,7 +230,7 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
* search: string = 'coreTeam=true';
* }
*
* bootstrap(App, [JSONP_PROVIDERS, provide(RequestOptions, {asClass: MyOptions})])
* bootstrap(App, [JSONP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})])
* .catch(err => console.error(err));
* ```
*
Expand All @@ -247,7 +247,7 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
* var injector = Injector.resolveAndCreate([
* JSONP_PROVIDERS,
* MockBackend,
* provide(JSONPBackend, {asAlias: MockBackend})
* provide(JSONPBackend, {useExisting: MockBackend})
* ]);
* var jsonp = injector.get(Jsonp);
* var backend = injector.get(MockBackend);
Expand Down Expand Up @@ -275,13 +275,13 @@ export const JSONP_PROVIDERS: any[] = [
// issue: https://github.com/angular/angular/issues/3183
provide(Jsonp,
{
asFactory: (jsonpBackend, requestOptions) => new Jsonp(jsonpBackend, requestOptions),
useFactory: (jsonpBackend, requestOptions) => new Jsonp(jsonpBackend, requestOptions),
deps: [JSONPBackend, RequestOptions]
}),
BrowserJsonp,
provide(RequestOptions, {asClass: BaseRequestOptions}),
provide(ResponseOptions, {asClass: BaseResponseOptions}),
provide(JSONPBackend, {asClass: JSONPBackend_})
provide(RequestOptions, {useClass: BaseRequestOptions}),
provide(ResponseOptions, {useClass: BaseResponseOptions}),
provide(JSONPBackend, {useClass: JSONPBackend_})
];

/**
Expand Down
6 changes: 3 additions & 3 deletions modules/angular2/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ export const ROUTER_DIRECTIVES: any[] = CONST_EXPR([RouterOutlet, RouterLink]);
*/
export const ROUTER_PROVIDERS: any[] = CONST_EXPR([
RouteRegistry,
CONST_EXPR(new Provider(LocationStrategy, {toClass: PathLocationStrategy})),
CONST_EXPR(new Provider(LocationStrategy, {useClass: PathLocationStrategy})),
Location,
CONST_EXPR(
new Provider(Router,
{
toFactory: routerFactory,
useFactory: routerFactory,
deps: CONST_EXPR([RouteRegistry, Location, ROUTER_PRIMARY_COMPONENT])
})),
CONST_EXPR(new Provider(
ROUTER_PRIMARY_COMPONENT,
{toFactory: routerPrimaryComponentFactory, deps: CONST_EXPR([ApplicationRef])}))
{useFactory: routerPrimaryComponentFactory, deps: CONST_EXPR([ApplicationRef])}))
]);

/**
Expand Down
16 changes: 8 additions & 8 deletions modules/angular2/src/core/application_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ export function applicationDomBindings(): Array<Type | Provider | any[]> {
throw "Must set a root DOM adapter first.";
}
return [
provide(DOCUMENT, {asValue: DOM.defaultDoc()}),
provide(DOCUMENT, {useValue: DOM.defaultDoc()}),
EventManager,
new Provider(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}),
new Provider(EVENT_MANAGER_PLUGINS, {toClass: KeyEventsPlugin, multi: true}),
new Provider(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}),
provide(DomRenderer, {asClass: DomRenderer_}),
provide(Renderer, {asAlias: DomRenderer}),
new Provider(EVENT_MANAGER_PLUGINS, {useClass: DomEventsPlugin, multi: true}),
new Provider(EVENT_MANAGER_PLUGINS, {useClass: KeyEventsPlugin, multi: true}),
new Provider(EVENT_MANAGER_PLUGINS, {useClass: HammerGesturesPlugin, multi: true}),
provide(DomRenderer, {useClass: DomRenderer_}),
provide(Renderer, {useExisting: DomRenderer}),
DomSharedStylesHost,
provide(SharedStylesHost, {asAlias: DomSharedStylesHost}),
provide(SharedStylesHost, {useExisting: DomSharedStylesHost}),
EXCEPTION_PROVIDER,
provide(XHR, {asValue: new XHRImpl()}),
provide(XHR, {useValue: new XHRImpl()}),
Testability,
BrowserDetails,
AnimationBuilder,
Expand Down
28 changes: 14 additions & 14 deletions modules/angular2/src/core/application_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ import {Compiler_} from "./linker/compiler";
* running on the page.
*/
export function platformBindings(): Array<Type | Provider | any[]> {
return [provide(Reflector, {asValue: reflector}), TestabilityRegistry];
return [provide(Reflector, {useValue: reflector}), TestabilityRegistry];
}

/**
* Construct providers specific to an individual root component.
*/
function _componentProviders(appComponentType: Type): Array<Type | Provider | any[]> {
return [
provide(APP_COMPONENT, {asValue: appComponentType}),
provide(APP_COMPONENT, {useValue: appComponentType}),
provide(APP_COMPONENT_REF_PROMISE,
{
asFactory: (dynamicComponentLoader, injector: Injector) => {
useFactory: (dynamicComponentLoader, injector: Injector) => {
// TODO(rado): investigate whether to support bindings on root component.
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
.then((componentRef) => {
Expand All @@ -77,7 +77,7 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
}),
provide(appComponentType,
{
asFactory: (p: Promise<any>) => p.then(ref => ref.instance),
useFactory: (p: Promise<any>) => p.then(ref => ref.instance),
deps: [APP_COMPONENT_REF_PROMISE]
}),
];
Expand All @@ -89,24 +89,24 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
*/
export function applicationCommonBindings(): Array<Type | Provider | any[]> {
return [
provide(Compiler, {asClass: Compiler_}),
provide(Compiler, {useClass: Compiler_}),
APP_ID_RANDOM_PROVIDER,
AppViewPool,
provide(APP_VIEW_POOL_CAPACITY, {asValue: 10000}),
provide(AppViewManager, {asClass: AppViewManager_}),
provide(APP_VIEW_POOL_CAPACITY, {useValue: 10000}),
provide(AppViewManager, {useClass: AppViewManager_}),
AppViewManagerUtils,
AppViewListener,
ProtoViewFactory,
ViewResolver,
DEFAULT_PIPES,
provide(IterableDiffers, {asValue: defaultIterableDiffers}),
provide(KeyValueDiffers, {asValue: defaultKeyValueDiffers}),
provide(IterableDiffers, {useValue: defaultIterableDiffers}),
provide(KeyValueDiffers, {useValue: defaultKeyValueDiffers}),
DirectiveResolver,
PipeResolver,
provide(DynamicComponentLoader, {asClass: DynamicComponentLoader_}),
provide(DynamicComponentLoader, {useClass: DynamicComponentLoader_}),
provide(LifeCycle,
{
asFactory: (exceptionHandler) => new LifeCycle_(null, assertionsEnabled()),
useFactory: (exceptionHandler) => new LifeCycle_(null, assertionsEnabled()),
deps: [ExceptionHandler]
})
];
Expand Down Expand Up @@ -236,8 +236,8 @@ export class PlatformRef_ extends PlatformRef {
var injector: Injector;
var app: ApplicationRef;
zone.run(() => {
providers.push(provide(NgZone, {asValue: zone}));
providers.push(provide(ApplicationRef, {asFactory: (): ApplicationRef => app, deps: []}));
providers.push(provide(NgZone, {useValue: zone}));
providers.push(provide(ApplicationRef, {useFactory: (): ApplicationRef => app, deps: []}));

var exceptionHandler;
try {
Expand Down Expand Up @@ -297,7 +297,7 @@ export abstract class ApplicationRef {
* ```
* var app = platform.application([applicationCommonBindings(), applicationDomBindings()];
* app.bootstrap(FirstRootComponent);
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {asClass: OverriddenBinding})]);
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]);
* ```
*/
abstract bootstrap(componentType: Type, bindings?: Array<Type | Provider | any[]>):
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/core/application_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function _appIdRandomProviderFactory() {
* Bindings that will generate a random APP_ID_TOKEN.
*/
export const APP_ID_RANDOM_PROVIDER: Provider =
CONST_EXPR(new Provider(APP_ID, {toFactory: _appIdRandomProviderFactory, deps: []}));
CONST_EXPR(new Provider(APP_ID, {useFactory: _appIdRandomProviderFactory, deps: []}));

function _randomChar(): string {
return StringWrapper.fromCharCode(97 + Math.floor(Math.random() * 25));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class IterableDiffers {
*/
static extend(factories: IterableDifferFactory[]): Provider {
return new Provider(IterableDiffers, {
toFactory: (parent: IterableDiffers) => {
useFactory: (parent: IterableDiffers) => {
if (isBlank(parent)) {
// Typically would occur when calling IterableDiffers.extend inside of dependencies passed
// to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class KeyValueDiffers {
*/
static extend(factories: KeyValueDifferFactory[]): Provider {
return new Provider(KeyValueDiffers, {
toFactory: (parent: KeyValueDiffers) => {
useFactory: (parent: KeyValueDiffers) => {
if (isBlank(parent)) {
// Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
// to
Expand Down
10 changes: 5 additions & 5 deletions modules/angular2/src/core/compiler/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ export function compilerProviders(): Array<Type | Provider | any[]> {
ChangeDetectionCompiler,
provide(ChangeDetectorGenConfig,
{
asValue:
useValue:
new ChangeDetectorGenConfig(assertionsEnabled(), assertionsEnabled(), false, true)
}),
TemplateCompiler,
provide(RuntimeCompiler, {asClass: RuntimeCompiler_}),
provide(Compiler, {asAlias: RuntimeCompiler}),
provide(RuntimeCompiler, {useClass: RuntimeCompiler_}),
provide(Compiler, {useExisting: RuntimeCompiler}),
DomElementSchemaRegistry,
provide(ElementSchemaRegistry, {asAlias: DomElementSchemaRegistry}),
provide(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}),
AnchorBasedAppRootUrl,
provide(AppRootUrl, {asAlias: AnchorBasedAppRootUrl}),
provide(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
UrlResolver
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DebugElementViewListener implements AppViewListener {

export const ELEMENT_PROBE_PROVIDERS: any[] = CONST_EXPR([
DebugElementViewListener,
CONST_EXPR(new Provider(AppViewListener, {toAlias: DebugElementViewListener})),
CONST_EXPR(new Provider(AppViewListener, {useExisting: DebugElementViewListener})),
]);

export const ELEMENT_PROBE_BINDINGS = ELEMENT_PROBE_PROVIDERS;
8 changes: 4 additions & 4 deletions modules/angular2/src/core/di/exceptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export class NoProviderError extends AbstractProviderError {
*
* ```typescript
* var injector = Injector.resolveAndCreate([
* provide("one", {asFactory: (two) => "two", deps: [[new Inject("two")]]}),
* provide("two", {asFactory: (one) => "one", deps: [[new Inject("one")]]})
* provide("one", {useFactory: (two) => "two", deps: [[new Inject("two")]]}),
* provide("two", {useFactory: (one) => "one", deps: [[new Inject("one")]]})
* ]);
*
* expect(() => injector.get("one")).toThrowError();
Expand Down Expand Up @@ -252,8 +252,8 @@ export class OutOfBoundsError extends BaseException {
*
* ```typescript
* expect(() => Injector.resolveAndCreate([
* new Provider("Strings", {toValue: "string1", multi: true}),
* new Provider("Strings", {toValue: "string2", multi: false})
* new Provider("Strings", {useValue: "string1", multi: true}),
* new Provider("Strings", {useValue: "string2", multi: false})
* ])).toThrowError();
* ```
*/
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/src/core/di/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ export class Injector {
*
* ```typescript
* var injector = Injector.resolveAndCreate([
* provide("validToken", {asValue: "Value"})
* provide("validToken", {useValue: "Value"})
* ]);
* expect(injector.get("validToken")).toEqual("Value");
* expect(() => injector.get("invalidToken")).toThrowError();
Expand All @@ -588,7 +588,7 @@ export class Injector {
*
* ```typescript
* var injector = Injector.resolveAndCreate([
* provide("validToken", {asValue: "Value"})
* provide("validToken", {useValue: "Value"})
* ]);
* expect(injector.getOptional("validToken")).toEqual("Value");
* expect(injector.getOptional("invalidToken")).toBe(null);
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/core/di/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {CONST, CONST_EXPR, stringify, isBlank, isPresent} from "angular2/src/cor
* }
*
* var injector = Injector.resolveAndCreate([
* provide("MyEngine", {asClass: Engine}),
* provide("MyEngine", {useClass: Engine}),
* Car
* ]);
*
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/core/di/opaque_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {CONST} from 'angular2/src/core/facade/lang';
* var t = new OpaqueToken("value");
*
* var injector = Injector.resolveAndCreate([
* provide(t, {asValue: "providedValue"})
* provide(t, {useValue: "providedValue"})
* ]);
*
* expect(injector.get(t)).toEqual("bindingValue");
Expand Down
Loading
X Tutup