chore: remove const Provider() in favor of /* @ts2dart_Provider */ {provide:}
This commit is contained in:
parent
3aa322a9c6
commit
a8e277b067
|
@ -47,7 +47,7 @@ function createNgZone(): NgZone {
|
|||
* Default platform providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/ [
|
||||
/*@ts2dart_const*/[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
/*@ts2dart_Provider*/{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
||||
];
|
||||
|
|
|
@ -49,9 +49,9 @@ function initServerTests() {
|
|||
* Default platform providers for testing.
|
||||
*/
|
||||
export const TEST_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/ [
|
||||
/*@ts2dart_const*/[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
/*@ts2dart_Provider*/{provide: PLATFORM_INITIALIZER, useValue: initServerTests, multi: true}
|
||||
/*@ts2dart_Provider*/ {provide: PLATFORM_INITIALIZER, useValue: initServerTests, multi: true}
|
||||
];
|
||||
|
||||
function appDoc() {
|
||||
|
@ -66,26 +66,26 @@ function appDoc() {
|
|||
* Default application providers for testing.
|
||||
*/
|
||||
export const TEST_SERVER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/ [
|
||||
/*@ts2dart_const*/[
|
||||
// TODO(julie: when angular2/platform/server is available, use that instead of making our own
|
||||
// list here.
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
COMPILER_PROVIDERS,
|
||||
/*@ts2dart_Provider*/{provide: DOCUMENT, useFactory: appDoc},
|
||||
/*@ts2dart_Provider*/{provide: DomRootRenderer, useClass: DomRootRenderer_},
|
||||
/*@ts2dart_Provider*/{provide: RootRenderer, useExisting: DomRootRenderer},
|
||||
/* @ts2dart_Provider */ {provide: DOCUMENT, useFactory: appDoc},
|
||||
/* @ts2dart_Provider */ {provide: DomRootRenderer, useClass: DomRootRenderer_},
|
||||
/* @ts2dart_Provider */ {provide: RootRenderer, useExisting: DomRootRenderer},
|
||||
EventManager,
|
||||
/*@ts2dart_Provider*/{provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true},
|
||||
/*@ts2dart_Provider*/{provide: XHR, useClass: XHR},
|
||||
/*@ts2dart_Provider*/{provide: APP_ID, useValue: 'a'},
|
||||
/*@ts2dart_Provider*/{provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
/* @ts2dart_Provider */ {provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: XHR, useClass: XHR},
|
||||
/* @ts2dart_Provider */ {provide: APP_ID, useValue: 'a'},
|
||||
/* @ts2dart_Provider */ {provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
DomSharedStylesHost,
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
/*@ts2dart_Provider*/{provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
||||
/*@ts2dart_Provider*/{provide: ViewResolver, useClass: MockViewResolver},
|
||||
/* @ts2dart_Provider */ {provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
||||
/* @ts2dart_Provider */ {provide: ViewResolver, useClass: MockViewResolver},
|
||||
Log,
|
||||
TestComponentBuilder,
|
||||
/*@ts2dart_Provider*/{provide: NgZone, useFactory: createNgZone},
|
||||
/*@ts2dart_Provider*/{provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
/*@ts2dart_Provider*/{provide: AnimationBuilder, useClass: MockAnimationBuilder},
|
||||
/* @ts2dart_Provider */ {provide: NgZone, useFactory: createNgZone},
|
||||
/* @ts2dart_Provider */ {provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
/* @ts2dart_Provider */ {provide: AnimationBuilder, useClass: MockAnimationBuilder},
|
||||
];
|
||||
|
|
|
@ -57,7 +57,7 @@ export function bootstrapRender(
|
|||
var app = ReflectiveInjector.resolveAndCreate(
|
||||
[
|
||||
WORKER_RENDER_APPLICATION,
|
||||
new Provider(WORKER_SCRIPT, {useValue: workerScriptUri}),
|
||||
/* @ts2dart_Provider */ {provide: WORKER_SCRIPT, useValue: workerScriptUri},
|
||||
isPresent(customProviders) ? customProviders : []
|
||||
],
|
||||
workerRenderPlatform().injector);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {TEMPLATE_TRANSFORMS} from 'angular2/compiler';
|
||||
import {Provider} from 'angular2/core';
|
||||
import {RouterLinkTransform} from 'angular2/src/router/directives/router_link_transform';
|
||||
|
||||
export {RouterLinkTransform} from 'angular2/src/router/directives/router_link_transform';
|
||||
|
@ -31,5 +30,8 @@ export {RouterLinkTransform} from 'angular2/src/router/directives/router_link_tr
|
|||
* ```
|
||||
*/
|
||||
export const ROUTER_LINK_DSL_PROVIDER =
|
||||
/*@ts2dart_const*/
|
||||
new Provider(TEMPLATE_TRANSFORMS, {useClass: RouterLinkTransform, multi: true});
|
||||
/*@ts2dart_const*/ /* @ts2dart_Provider */ {
|
||||
provide: TEMPLATE_TRANSFORMS,
|
||||
useClass: RouterLinkTransform,
|
||||
multi: true
|
||||
};
|
||||
|
|
|
@ -2,8 +2,11 @@ import {Directive, Renderer, ElementRef, Self, forwardRef, Provider} from 'angul
|
|||
|
||||
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from './control_value_accessor';
|
||||
|
||||
export const CHECKBOX_VALUE_ACCESSOR = /*@ts2dart_const*/ new Provider(
|
||||
NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => CheckboxControlValueAccessor), multi: true});
|
||||
export const CHECKBOX_VALUE_ACCESSOR: any = /*@ts2dart_const*/ {
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => CheckboxControlValueAccessor),
|
||||
multi: true
|
||||
};
|
||||
|
||||
/**
|
||||
* The accessor for writing a value and listening to changes on a checkbox input element.
|
||||
|
|
|
@ -2,8 +2,12 @@ import {Directive, ElementRef, Renderer, Self, forwardRef, Provider} from 'angul
|
|||
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from './control_value_accessor';
|
||||
import {isBlank} from 'angular2/src/facade/lang';
|
||||
|
||||
export const DEFAULT_VALUE_ACCESSOR = /*@ts2dart_const*/ new Provider(
|
||||
NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => DefaultValueAccessor), multi: true});
|
||||
export const DEFAULT_VALUE_ACCESSOR: any = /*@ts2dart_const*/
|
||||
/* @ts2dart_Provider */ {
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => DefaultValueAccessor),
|
||||
multi: true
|
||||
};
|
||||
|
||||
/**
|
||||
* The default accessor for writing a value and listening to changes that is used by the
|
||||
|
|
|
@ -18,9 +18,11 @@ import {Form} from './form_interface';
|
|||
import {NG_VALIDATORS, NG_ASYNC_VALIDATORS} from '../validators';
|
||||
import {AsyncValidatorFn, ValidatorFn} from './validators';
|
||||
|
||||
export const controlGroupProvider =
|
||||
/*@ts2dart_const*/
|
||||
new Provider(ControlContainer, {useExisting: forwardRef(() => NgControlGroup)});
|
||||
export const controlGroupProvider: any =
|
||||
/*@ts2dart_const*/ /* @ts2dart_Provider */ {
|
||||
provide: ControlContainer,
|
||||
useExisting: forwardRef(() => NgControlGroup)
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates and binds a control group to a DOM element.
|
||||
|
|
|
@ -30,8 +30,11 @@ import {NG_VALIDATORS, NG_ASYNC_VALIDATORS} from '../validators';
|
|||
import {ValidatorFn, AsyncValidatorFn} from './validators';
|
||||
|
||||
|
||||
export const controlNameBinding =
|
||||
/*@ts2dart_const*/ new Provider(NgControl, {useExisting: forwardRef(() => NgControlName)});
|
||||
export const controlNameBinding: any =
|
||||
/*@ts2dart_const*/ /* @ts2dart_Provider */ {
|
||||
provide: NgControl,
|
||||
useExisting: forwardRef(() => NgControlName)
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates and binds a control with a specified name to a DOM element.
|
||||
|
|
|
@ -15,8 +15,11 @@ import {AbstractControl, ControlGroup, Control} from '../model';
|
|||
import {setUpControl, setUpControlGroup, composeValidators, composeAsyncValidators} from './shared';
|
||||
import {Validators, NG_VALIDATORS, NG_ASYNC_VALIDATORS} from '../validators';
|
||||
|
||||
const formDirectiveProvider =
|
||||
/*@ts2dart_const*/ new Provider(ControlContainer, {useExisting: forwardRef(() => NgForm)});
|
||||
export const formDirectiveProvider: any =
|
||||
/*@ts2dart_const*/ /* @ts2dart_Provider */ {
|
||||
provide: ControlContainer,
|
||||
useExisting: forwardRef(() => NgForm)
|
||||
};
|
||||
|
||||
/**
|
||||
* If `NgForm` is bound in a component, `<form>` elements in that component will be
|
||||
|
|
|
@ -24,8 +24,11 @@ import {
|
|||
} from './shared';
|
||||
import {ValidatorFn, AsyncValidatorFn} from './validators';
|
||||
|
||||
const formControlBinding =
|
||||
/*@ts2dart_const*/ new Provider(NgControl, {useExisting: forwardRef(() => NgFormControl)});
|
||||
export const formControlBinding: any =
|
||||
/*@ts2dart_const*/ /* @ts2dart_Provider */ {
|
||||
provide: NgControl,
|
||||
useExisting: forwardRef(() => NgFormControl)
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds an existing {@link Control} to a DOM element.
|
||||
|
|
|
@ -20,9 +20,11 @@ import {Control, ControlGroup} from '../model';
|
|||
import {setUpControl, setUpControlGroup, composeValidators, composeAsyncValidators} from './shared';
|
||||
import {Validators, NG_VALIDATORS, NG_ASYNC_VALIDATORS} from '../validators';
|
||||
|
||||
export const formDirectiveProvider =
|
||||
/*@ts2dart_const*/
|
||||
new Provider(ControlContainer, {useExisting: forwardRef(() => NgFormModel)});
|
||||
export const formDirectiveProvider: any =
|
||||
/*@ts2dart_const*/ /* @ts2dart_Provider */ {
|
||||
provide: ControlContainer,
|
||||
useExisting: forwardRef(() => NgFormModel)
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds an existing control group to a DOM element.
|
||||
|
|
|
@ -22,8 +22,11 @@ import {
|
|||
} from './shared';
|
||||
import {ValidatorFn, AsyncValidatorFn} from './validators';
|
||||
|
||||
export const formControlBinding =
|
||||
/*@ts2dart_const*/ new Provider(NgControl, {useExisting: forwardRef(() => NgModel)});
|
||||
export const formControlBinding: any =
|
||||
/*@ts2dart_const*/ /* @ts2dart_Provider */ {
|
||||
provide: NgControl,
|
||||
useExisting: forwardRef(() => NgModel)
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds a domain model to a form control.
|
||||
|
|
|
@ -21,7 +21,7 @@ import {looseIdentical, isPresent} from 'angular2/src/facade/lang';
|
|||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
export const RADIO_VALUE_ACCESSOR: any = /*@ts2dart_const*/ /*@ts2dart_Provider*/ {
|
||||
povide: NG_VALUE_ACCESSOR,
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => RadioControlValueAccessor),
|
||||
multi: true
|
||||
};
|
||||
|
|
|
@ -62,12 +62,11 @@ export interface AsyncValidatorFn {
|
|||
*
|
||||
* {@example common/forms/ts/validators/validators.ts region='min'}
|
||||
*/
|
||||
export const MIN_LENGTH_VALIDATOR: any = /*@ts2dart_const*/
|
||||
/*@ts2dart_Provider*/ {
|
||||
provide: NG_VALIDATORS,
|
||||
useExisting: forwardRef(() => MinLengthValidator),
|
||||
multi: true
|
||||
};
|
||||
export const MIN_LENGTH_VALIDATOR: any = /*@ts2dart_const*/ /*@ts2dart_Provider*/ {
|
||||
provide: NG_VALIDATORS,
|
||||
useExisting: forwardRef(() => MinLengthValidator),
|
||||
multi: true
|
||||
};
|
||||
|
||||
/**
|
||||
* A directive which installs the {@link MinLengthValidator} for any `ngControl`,
|
||||
|
@ -94,12 +93,11 @@ export class MinLengthValidator implements Validator {
|
|||
*
|
||||
* {@example common/forms/ts/validators/validators.ts region='max'}
|
||||
*/
|
||||
export const MAX_LENGTH_VALIDATOR: any = /*@ts2dart_const*/
|
||||
/*@ts2dart_Provider*/ {
|
||||
provide: NG_VALIDATORS,
|
||||
useExisting: forwardRef(() => MaxLengthValidator),
|
||||
multi: true
|
||||
};
|
||||
export const MAX_LENGTH_VALIDATOR: any = /*@ts2dart_const*/ /*@ts2dart_Provider*/ {
|
||||
provide: NG_VALIDATORS,
|
||||
useExisting: forwardRef(() => MaxLengthValidator),
|
||||
multi: true
|
||||
};
|
||||
|
||||
/**
|
||||
* A directive which installs the {@link MaxLengthValidator} for any `ngControl, `ngFormControl`,
|
||||
|
@ -132,12 +130,11 @@ export class MaxLengthValidator implements Validator {
|
|||
* <input [ngControl]="fullName" pattern="[a-zA-Z ]*">
|
||||
* ```
|
||||
*/
|
||||
export const PATTERN_VALIDATOR: any = /*@ts2dart_const*/
|
||||
/*@ts2dart_Provider*/ {
|
||||
provide: NG_VALIDATORS,
|
||||
useExisting: forwardRef(() => PatternValidator),
|
||||
multi: true
|
||||
};
|
||||
export const PATTERN_VALIDATOR: any = /*@ts2dart_const*/ /*@ts2dart_Provider*/ {
|
||||
provide: NG_VALIDATORS,
|
||||
useExisting: forwardRef(() => PatternValidator),
|
||||
multi: true
|
||||
};
|
||||
@Directive({
|
||||
selector: '[pattern][ngControl],[pattern][ngFormControl],[pattern][ngModel]',
|
||||
providers: [PATTERN_VALIDATOR]
|
||||
|
|
|
@ -83,7 +83,6 @@ var defaultLocale: string = 'en-US';
|
|||
*
|
||||
* {@example core/pipes/ts/date_pipe/date_pipe_example.ts region='DatePipe'}
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Pipe({name: 'date', pure: true})
|
||||
@Injectable()
|
||||
export class DatePipe implements PipeTransform {
|
||||
|
|
|
@ -35,7 +35,6 @@ var interpolationExp: RegExp = RegExpWrapper.create('#');
|
|||
* ```
|
||||
*
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Pipe({name: 'i18nPlural', pure: true})
|
||||
@Injectable()
|
||||
export class I18nPluralPipe implements PipeTransform {
|
||||
|
|
|
@ -32,7 +32,6 @@ import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
|||
* }
|
||||
* ```
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Pipe({name: 'i18nSelect', pure: true})
|
||||
@Injectable()
|
||||
export class I18nSelectPipe implements PipeTransform {
|
||||
|
|
|
@ -9,7 +9,6 @@ import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
|||
*
|
||||
* {@example core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts region='LowerUpperPipe'}
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Pipe({name: 'lowercase'})
|
||||
@Injectable()
|
||||
export class LowerCasePipe implements PipeTransform {
|
||||
|
|
|
@ -19,7 +19,6 @@ var _re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
|
|||
/**
|
||||
* Internal base class for numeric pipes.
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Injectable()
|
||||
export class NumberPipe {
|
||||
/** @internal */
|
||||
|
@ -81,7 +80,6 @@ export class NumberPipe {
|
|||
*
|
||||
* {@example core/pipes/ts/number_pipe/number_pipe_example.ts region='NumberPipe'}
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Pipe({name: 'number'})
|
||||
@Injectable()
|
||||
export class DecimalPipe extends NumberPipe implements PipeTransform {
|
||||
|
@ -106,7 +104,6 @@ export class DecimalPipe extends NumberPipe implements PipeTransform {
|
|||
*
|
||||
* {@example core/pipes/ts/number_pipe/number_pipe_example.ts region='PercentPipe'}
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Pipe({name: 'percent'})
|
||||
@Injectable()
|
||||
export class PercentPipe extends NumberPipe implements PipeTransform {
|
||||
|
@ -135,7 +132,6 @@ export class PercentPipe extends NumberPipe implements PipeTransform {
|
|||
*
|
||||
* {@example core/pipes/ts/number_pipe/number_pipe_example.ts region='CurrencyPipe'}
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Pipe({name: 'currency'})
|
||||
@Injectable()
|
||||
export class CurrencyPipe extends NumberPipe implements PipeTransform {
|
||||
|
|
|
@ -9,7 +9,6 @@ import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
|||
*
|
||||
* {@example core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts region='LowerUpperPipe'}
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
@Pipe({name: 'uppercase'})
|
||||
@Injectable()
|
||||
export class UpperCasePipe implements PipeTransform {
|
||||
|
|
|
@ -13,7 +13,6 @@ export {DirectiveResolver} from './directive_resolver';
|
|||
export {PipeResolver} from './pipe_resolver';
|
||||
|
||||
import {assertionsEnabled, Type} from 'angular2/src/facade/lang';
|
||||
import {provide, Provider} from 'angular2/src/core/di';
|
||||
import {TemplateParser} from 'angular2/src/compiler/template_parser';
|
||||
import {HtmlParser} from 'angular2/src/compiler/html_parser';
|
||||
import {DirectiveNormalizer} from 'angular2/src/compiler/directive_normalizer';
|
||||
|
@ -40,7 +39,7 @@ function _createCompilerConfig() {
|
|||
* A set of providers that provide `RuntimeCompiler` and its dependencies to use for
|
||||
* template compilation.
|
||||
*/
|
||||
export const COMPILER_PROVIDERS: Array<any | Type | Provider | any[]> = /*@ts2dart_const*/ [
|
||||
export const COMPILER_PROVIDERS: Array<any | Type | {[k: string]: any} | any[]> = /*@ts2dart_const*/ [
|
||||
Lexer,
|
||||
Parser,
|
||||
HtmlParser,
|
||||
|
|
|
@ -37,6 +37,7 @@ import {
|
|||
} from 'angular2/src/core/di/metadata';
|
||||
import {AttributeMetadata, QueryMetadata} from 'angular2/src/core/metadata/di';
|
||||
import {ReflectorReader} from 'angular2/src/core/reflection/reflector_reader';
|
||||
import {isProviderLiteral, createProvider} from '../core/di/provider_util';
|
||||
|
||||
@Injectable()
|
||||
export class CompileMetadataResolver {
|
||||
|
@ -292,6 +293,8 @@ export class CompileMetadataResolver {
|
|||
return this.getProvidersMetadata(provider);
|
||||
} else if (provider instanceof Provider) {
|
||||
return this.getProviderMetadata(provider);
|
||||
} else if (isProviderLiteral(provider)) {
|
||||
return this.getProviderMetadata(createProvider(provider));
|
||||
} else {
|
||||
return this.getTypeMetadata(provider, staticTypeModuleUrl(provider));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
} from 'angular2/src/facade/lang';
|
||||
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
|
||||
|
||||
const _EMPTY_ATTR_VALUE = '';
|
||||
const _EMPTY_ATTR_VALUE = /*@ts2dart_const*/ '';
|
||||
|
||||
// TODO: Can't use `const` here as
|
||||
// in Dart this is not transpiled into `final` yet...
|
||||
|
|
|
@ -4,13 +4,7 @@ import {
|
|||
SetWrapper,
|
||||
MapWrapper
|
||||
} from 'angular2/src/facade/collection';
|
||||
import {
|
||||
RegExpWrapper,
|
||||
isPresent,
|
||||
StringWrapper,
|
||||
isBlank,
|
||||
isArray
|
||||
} from 'angular2/src/facade/lang';
|
||||
import {RegExpWrapper, isPresent, StringWrapper, isBlank, isArray} from 'angular2/src/facade/lang';
|
||||
import {Injectable, Inject, OpaqueToken, Optional} from 'angular2/core';
|
||||
import {Console} from 'angular2/src/core/console';
|
||||
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||
|
@ -113,7 +107,7 @@ var TEXT_CSS_SELECTOR = CssSelector.parse('*')[0];
|
|||
*
|
||||
* This is currently an internal-only feature and not meant for general use.
|
||||
*/
|
||||
export const TEMPLATE_TRANSFORMS = /*@ts2dart_const*/ new OpaqueToken('TemplateTransforms');
|
||||
export const TEMPLATE_TRANSFORMS: any = /*@ts2dart_const*/ new OpaqueToken('TemplateTransforms');
|
||||
|
||||
export class TemplateParseError extends ParseError {
|
||||
constructor(message: string, span: ParseSourceSpan, level: ParseErrorLevel) {
|
||||
|
|
|
@ -26,7 +26,10 @@ export function createOfflineCompileUrlResolver(): UrlResolver {
|
|||
/**
|
||||
* A default provider for {@link PACKAGE_ROOT_URL} that maps to '/'.
|
||||
*/
|
||||
export var DEFAULT_PACKAGE_URL_PROVIDER = new Provider(PACKAGE_ROOT_URL, {useValue: "/"});
|
||||
export var DEFAULT_PACKAGE_URL_PROVIDER = {
|
||||
provide: PACKAGE_ROOT_URL,
|
||||
useValue: "/"
|
||||
};
|
||||
|
||||
/**
|
||||
* Used by the {@link Compiler} when resolving HTML and CSS template URLs.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {Type} from 'angular2/src/facade/lang';
|
||||
import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {APP_ID_RANDOM_PROVIDER} from './application_tokens';
|
||||
import {APPLICATION_CORE_PROVIDERS} from './application_ref';
|
||||
import {
|
||||
|
@ -18,13 +17,13 @@ let __unused: Type; // avoid unused import when Type union types are erased
|
|||
* A default set of providers which should be included in any Angular
|
||||
* application, regardless of the platform it runs onto.
|
||||
*/
|
||||
export const APPLICATION_COMMON_PROVIDERS: Array<any | Type | Provider | any[]> =
|
||||
export const APPLICATION_COMMON_PROVIDERS: Array<Type | {[k: string]: any} | any[]> =
|
||||
/*@ts2dart_const*/[
|
||||
APPLICATION_CORE_PROVIDERS,
|
||||
/*@ts2dart_const*/ {provide: ComponentResolver, useClass: ReflectorComponentResolver},
|
||||
/* @ts2dart_Provider */ {provide: ComponentResolver, useClass: ReflectorComponentResolver},
|
||||
APP_ID_RANDOM_PROVIDER,
|
||||
ViewUtils,
|
||||
/*@ts2dart_const*/ {provide: IterableDiffers, useValue: defaultIterableDiffers},
|
||||
/*@ts2dart_const*/ {provide: KeyValueDiffers, useValue: defaultKeyValueDiffers},
|
||||
/*@ts2dart_const*/ {provide: DynamicComponentLoader, useClass: DynamicComponentLoader_},
|
||||
/* @ts2dart_Provider */ {provide: IterableDiffers, useValue: defaultIterableDiffers},
|
||||
/* @ts2dart_Provider */ {provide: KeyValueDiffers, useValue: defaultKeyValueDiffers},
|
||||
/* @ts2dart_Provider */ {provide: DynamicComponentLoader, useClass: DynamicComponentLoader_}
|
||||
];
|
||||
|
|
|
@ -435,13 +435,19 @@ export class ApplicationRef_ extends ApplicationRef {
|
|||
* @internal
|
||||
*/
|
||||
export const PLATFORM_CORE_PROVIDERS =
|
||||
/*@ts2dart_const*/[PlatformRef_, new Provider(PlatformRef, {useExisting: PlatformRef_})];
|
||||
/*@ts2dart_const*/[
|
||||
PlatformRef_,
|
||||
/*@ts2dart_const*/ (/* @ts2dart_Provider */ {
|
||||
provide: PlatformRef,
|
||||
useExisting: PlatformRef_
|
||||
})
|
||||
];
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const APPLICATION_CORE_PROVIDERS = /*@ts2dart_const*/[
|
||||
new Provider(NgZone, {useFactory: createNgZone, deps: []}),
|
||||
/* @ts2dart_Provider */ {provide: NgZone, useFactory: createNgZone, deps: []},
|
||||
ApplicationRef_,
|
||||
new Provider(ApplicationRef, {useExisting: ApplicationRef_})
|
||||
/* @ts2dart_Provider */ {provide: ApplicationRef, useExisting: ApplicationRef_}
|
||||
];
|
||||
|
|
|
@ -10,7 +10,7 @@ import {Math, StringWrapper} from 'angular2/src/facade/lang';
|
|||
* a custom value via a DI provider <!-- TODO: provider --> configuring the root {@link Injector}
|
||||
* using this token.
|
||||
*/
|
||||
export const APP_ID: OpaqueToken = /*@ts2dart_const*/ new OpaqueToken('AppId');
|
||||
export const APP_ID: any = /*@ts2dart_const*/ new OpaqueToken('AppId');
|
||||
|
||||
function _appIdRandomProviderFactory() {
|
||||
return `${_randomChar()}${_randomChar()}${_randomChar()}`;
|
||||
|
@ -19,8 +19,12 @@ function _appIdRandomProviderFactory() {
|
|||
/**
|
||||
* Providers that will generate a random APP_ID_TOKEN.
|
||||
*/
|
||||
export const APP_ID_RANDOM_PROVIDER: Provider =
|
||||
/*@ts2dart_const*/ new Provider(APP_ID, {useFactory: _appIdRandomProviderFactory, deps: []});
|
||||
export const APP_ID_RANDOM_PROVIDER =
|
||||
/*@ts2dart_const*/ /* @ts2dart_Provider */ {
|
||||
provide: APP_ID,
|
||||
useFactory: _appIdRandomProviderFactory,
|
||||
deps: []
|
||||
};
|
||||
|
||||
function _randomChar(): string {
|
||||
return StringWrapper.fromCharCode(97 + Math.floor(Math.random() * 25));
|
||||
|
@ -29,17 +33,17 @@ function _randomChar(): string {
|
|||
/**
|
||||
* A function that will be executed when a platform is initialized.
|
||||
*/
|
||||
export const PLATFORM_INITIALIZER: OpaqueToken =
|
||||
export const PLATFORM_INITIALIZER: any =
|
||||
/*@ts2dart_const*/ new OpaqueToken("Platform Initializer");
|
||||
|
||||
/**
|
||||
* A function that will be executed when an application is initialized.
|
||||
*/
|
||||
export const APP_INITIALIZER: OpaqueToken =
|
||||
export const APP_INITIALIZER: any =
|
||||
/*@ts2dart_const*/ new OpaqueToken("Application Initializer");
|
||||
|
||||
/**
|
||||
* A token which indicates the root directory of the application
|
||||
*/
|
||||
export const PACKAGE_ROOT_URL: OpaqueToken =
|
||||
export const PACKAGE_ROOT_URL: any =
|
||||
/*@ts2dart_const*/ new OpaqueToken("Application Packages Root URL");
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
} from 'angular2/src/facade/collection';
|
||||
|
||||
export {looseIdentical} from 'angular2/src/facade/lang';
|
||||
export var uninitialized: Object = /*@ts2dart_const*/<Object>(new Object());
|
||||
export var uninitialized: Object = /*@ts2dart_const*/ new Object();
|
||||
|
||||
export function devModeEqual(a: any, b: any): boolean {
|
||||
if (isListLikeIterable(a) && isListLikeIterable(b)) {
|
||||
|
|
|
@ -15,6 +15,7 @@ import {IterableDiffer, IterableDifferFactory, TrackByFn} from '../differs/itera
|
|||
|
||||
/* @ts2dart_const */
|
||||
export class DefaultIterableDifferFactory implements IterableDifferFactory {
|
||||
constructor() {}
|
||||
supports(obj: Object): boolean { return isListLikeIterable(obj); }
|
||||
create(cdRef: ChangeDetectorRef, trackByFn?: TrackByFn): DefaultIterableDiffer {
|
||||
return new DefaultIterableDiffer(trackByFn);
|
||||
|
|
|
@ -4,8 +4,8 @@ import {BaseException} from 'angular2/src/facade/exceptions';
|
|||
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
import {KeyValueDiffer, KeyValueDifferFactory} from '../differs/keyvalue_differs';
|
||||
|
||||
/*@ts2dart_const*/
|
||||
export class DefaultKeyValueDifferFactory implements KeyValueDifferFactory {
|
||||
/* @ts2dart_const */
|
||||
constructor() {}
|
||||
supports(obj: any): boolean { return obj instanceof Map || isJsObject(obj); }
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ export interface IterableDifferFactory {
|
|||
* A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class IterableDiffers {
|
||||
/*@ts2dart_const*/
|
||||
constructor(public factories: IterableDifferFactory[]) {}
|
||||
|
||||
static create(factories: IterableDifferFactory[], parent?: IterableDiffers): IterableDiffers {
|
||||
|
|
|
@ -24,8 +24,8 @@ export interface KeyValueDifferFactory {
|
|||
* A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class KeyValueDiffers {
|
||||
/*@ts2dart_const*/
|
||||
constructor(public factories: KeyValueDifferFactory[]) {}
|
||||
|
||||
static create(factories: KeyValueDifferFactory[], parent?: KeyValueDiffers): KeyValueDiffers {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {unimplemented} from 'angular2/src/facade/exceptions';
|
||||
|
||||
const _THROW_IF_NOT_FOUND = /*@ts2dart_const*/ new Object();
|
||||
export const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
||||
export const THROW_IF_NOT_FOUND = /*@ts2dart_const*/ _THROW_IF_NOT_FOUND;
|
||||
|
||||
export abstract class Injector {
|
||||
static THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
|
||||
|
|
|
@ -39,8 +39,8 @@ import {stringify, isBlank, isPresent} from "angular2/src/facade/lang";
|
|||
* var injector = Injector.resolveAndCreate([Engine, Car]);
|
||||
* expect(injector.get(Car).engine instanceof Engine).toBe(true);
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class InjectMetadata {
|
||||
constructor(public token) {}
|
||||
toString(): string { return `@Inject(${stringify(this.token)})`; }
|
||||
|
@ -66,8 +66,8 @@ export class InjectMetadata {
|
|||
* var injector = Injector.resolveAndCreate([Car]);
|
||||
* expect(injector.get(Car).engine).toBeNull();
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class OptionalMetadata {
|
||||
toString(): string { return `@Optional()`; }
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ export class OptionalMetadata {
|
|||
/**
|
||||
* `DependencyMetadata` is used by the framework to extend DI.
|
||||
* This is internal to Angular and should not be used directly.
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class DependencyMetadata {
|
||||
get token() { return null; }
|
||||
}
|
||||
|
@ -111,8 +111,8 @@ export class DependencyMetadata {
|
|||
* var injector = Injector.resolveAndCreate([NeedsService, UsefulService]);
|
||||
* expect(() => injector.get(NeedsService)).toThrowError();
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class InjectableMetadata {
|
||||
constructor() {}
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ export class InjectableMetadata {
|
|||
* var child = inj.resolveAndCreateChild([NeedsDependency]);
|
||||
* expect(() => child.get(NeedsDependency)).toThrowError();
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class SelfMetadata {
|
||||
toString(): string { return `@Self()`; }
|
||||
}
|
||||
|
@ -173,8 +173,8 @@ export class SelfMetadata {
|
|||
* var inj = Injector.resolveAndCreate([Dependency, NeedsDependency]);
|
||||
* expect(() => inj.get(NeedsDependency)).toThrowError();
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class SkipSelfMetadata {
|
||||
toString(): string { return `@SkipSelf()`; }
|
||||
}
|
||||
|
@ -232,8 +232,8 @@ export class SkipSelfMetadata {
|
|||
*
|
||||
* bootstrap(App);
|
||||
*```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class HostMetadata {
|
||||
toString(): string { return `@Host()`; }
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
*
|
||||
* Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
|
||||
* error messages.
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class OpaqueToken {
|
||||
constructor(private _desc: string) {}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import {BaseException} from 'angular2/src/facade/exceptions';
|
|||
*
|
||||
* expect(injector.get("message")).toEqual('Hello');
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class Provider {
|
||||
/**
|
||||
* Token used when retrieving this provider. Usually, it is a type {@link Type}.
|
||||
|
@ -45,11 +45,11 @@ export class Provider {
|
|||
*
|
||||
* var injectorClass = Injector.resolveAndCreate([
|
||||
* Car,
|
||||
* new Provider(Vehicle, { useClass: Car })
|
||||
* {provide: Vehicle, useClass: Car }
|
||||
* ]);
|
||||
* var injectorAlias = Injector.resolveAndCreate([
|
||||
* Car,
|
||||
* new Provider(Vehicle, { useExisting: Car })
|
||||
* {provide: Vehicle, useExisting: Car }
|
||||
* ]);
|
||||
*
|
||||
* expect(injectorClass.get(Vehicle)).not.toBe(injectorClass.get(Car));
|
||||
|
@ -94,11 +94,11 @@ export class Provider {
|
|||
*
|
||||
* var injectorAlias = Injector.resolveAndCreate([
|
||||
* Car,
|
||||
* new Provider(Vehicle, { useExisting: Car })
|
||||
* {provide: Vehicle, useExisting: Car }
|
||||
* ]);
|
||||
* var injectorClass = Injector.resolveAndCreate([
|
||||
* Car,
|
||||
* new Provider(Vehicle, { useClass: Car })
|
||||
* {provide: Vehicle, useClass: Car }
|
||||
* ]);
|
||||
*
|
||||
* expect(injectorAlias.get(Vehicle)).toBe(injectorAlias.get(Car));
|
||||
|
@ -117,7 +117,7 @@ export class Provider {
|
|||
*
|
||||
* ```typescript
|
||||
* var injector = Injector.resolveAndCreate([
|
||||
* new Provider(Number, { useFactory: () => { return 1+2; }}),
|
||||
* {provide: Number, useFactory: () => { return 1+2; }},
|
||||
* new Provider(String, { useFactory: (value) => { return "Value: " + value; },
|
||||
* deps: [Number] })
|
||||
* ]);
|
||||
|
@ -138,7 +138,7 @@ export class Provider {
|
|||
*
|
||||
* ```typescript
|
||||
* var injector = Injector.resolveAndCreate([
|
||||
* new Provider(Number, { useFactory: () => { return 1+2; }}),
|
||||
* {provide: Number, useFactory: () => { return 1+2; }},
|
||||
* new Provider(String, { useFactory: (value) => { return "Value: " + value; },
|
||||
* deps: [Number] })
|
||||
* ]);
|
||||
|
@ -208,8 +208,8 @@ export class Provider {
|
|||
* See {@link Provider} instead.
|
||||
*
|
||||
* @deprecated
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class Binding extends Provider {
|
||||
constructor(token, {toClass, toValue, toAlias, toFactory, deps, multi}: {
|
||||
toClass?: Type,
|
||||
|
|
|
@ -625,7 +625,7 @@ export class ReflectiveInjector_ implements ReflectiveInjector {
|
|||
*/
|
||||
debugContext(): any { return this._debugContext(); }
|
||||
|
||||
get(token: any, notFoundValue: any = THROW_IF_NOT_FOUND): any {
|
||||
get(token: any, notFoundValue: any = /*@ts2dart_const*/ THROW_IF_NOT_FOUND): any {
|
||||
return this._getByKey(ReflectiveKey.get(token), null, null, notFoundValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ export class ComponentRef_ extends ComponentRef {
|
|||
const EMPTY_CONTEXT = /*@ts2dart_const*/new Object();
|
||||
|
||||
export class ComponentFactory {
|
||||
/* @ts2dart_const */
|
||||
constructor(public selector: string, private _viewFactory: Function,
|
||||
private _componentType: Type) {}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import {isBlank, stringify} from 'angular2/src/facade/lang';
|
||||
import {Injector, THROW_IF_NOT_FOUND} from 'angular2/src/core/di/injector';
|
||||
import {AppView} from './view';
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ import {DependencyMetadata} from 'angular2/src/core/di/metadata';
|
|||
* A decorator can inject string literal `text` like so:
|
||||
*
|
||||
* {@example core/ts/metadata/metadata.ts region='attributeMetadata'}
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class AttributeMetadata extends DependencyMetadata {
|
||||
constructor(public attributeName: string) { super(); }
|
||||
|
||||
|
@ -140,8 +140,8 @@ export class AttributeMetadata extends DependencyMetadata {
|
|||
*
|
||||
* The injected object is an unmodifiable live list.
|
||||
* See {@link QueryList} for more details.
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class QueryMetadata extends DependencyMetadata {
|
||||
/**
|
||||
* whether we want to query only direct children (false) or all
|
||||
|
@ -207,8 +207,8 @@ export class QueryMetadata extends DependencyMetadata {
|
|||
* }
|
||||
* }
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class ContentChildrenMetadata extends QueryMetadata {
|
||||
constructor(_selector: Type | string,
|
||||
{descendants = false, read = null}: {descendants?: boolean, read?: any} = {}) {
|
||||
|
@ -236,8 +236,8 @@ export class ContentChildrenMetadata extends QueryMetadata {
|
|||
* }
|
||||
* }
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class ContentChildMetadata extends QueryMetadata {
|
||||
constructor(_selector: Type | string, {read = null}: {read?: any} = {}) {
|
||||
super(_selector, {descendants: true, first: true, read: read});
|
||||
|
@ -278,8 +278,8 @@ export class ContentChildMetadata extends QueryMetadata {
|
|||
*
|
||||
* The injected object is an iterable and observable live list.
|
||||
* See {@link QueryList} for more details.
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class ViewQueryMetadata extends QueryMetadata {
|
||||
constructor(_selector: Type | string,
|
||||
{descendants = false, first = false,
|
||||
|
@ -370,8 +370,8 @@ export class ViewQueryMetadata extends QueryMetadata {
|
|||
* }
|
||||
* }
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class ViewChildrenMetadata extends ViewQueryMetadata {
|
||||
constructor(_selector: Type | string, {read = null}: {read?: any} = {}) {
|
||||
super(_selector, {descendants: true, read: read});
|
||||
|
@ -447,8 +447,8 @@ export class ViewChildrenMetadata extends ViewQueryMetadata {
|
|||
* }
|
||||
* }
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class ViewChildMetadata extends ViewQueryMetadata {
|
||||
constructor(_selector: Type | string, {read = null}: {read?: any} = {}) {
|
||||
super(_selector, {descendants: true, first: true, read: read});
|
||||
|
|
|
@ -380,8 +380,8 @@ import {ViewEncapsulation} from 'angular2/src/core/metadata/view';
|
|||
* Note also that although the `<li></li>` template still exists inside the `<template></template>`,
|
||||
* the instantiated
|
||||
* view occurs on the second `<li></li>` which is a sibling to the `<template>` element.
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class DirectiveMetadata extends InjectableMetadata {
|
||||
/**
|
||||
* The CSS selector that triggers the instantiation of a directive.
|
||||
|
@ -783,8 +783,8 @@ export class DirectiveMetadata extends InjectableMetadata {
|
|||
* ### Example
|
||||
*
|
||||
* {@example core/ts/metadata/metadata.ts region='component'}
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class ComponentMetadata extends DirectiveMetadata {
|
||||
/**
|
||||
* Defines the used change detection strategy.
|
||||
|
@ -940,8 +940,8 @@ export class ComponentMetadata extends DirectiveMetadata {
|
|||
* ### Example
|
||||
*
|
||||
* {@example core/ts/metadata/metadata.ts region='pipe'}
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class PipeMetadata extends InjectableMetadata {
|
||||
name: string;
|
||||
/** @internal */
|
||||
|
@ -996,8 +996,8 @@ export class PipeMetadata extends InjectableMetadata {
|
|||
*
|
||||
* bootstrap(App);
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class InputMetadata {
|
||||
constructor(
|
||||
/**
|
||||
|
@ -1046,8 +1046,8 @@ export class InputMetadata {
|
|||
* }
|
||||
* bootstrap(App);
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class OutputMetadata {
|
||||
constructor(public bindingPropertyName?: string) {}
|
||||
}
|
||||
|
@ -1086,8 +1086,8 @@ export class OutputMetadata {
|
|||
*
|
||||
* bootstrap(App);
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class HostBindingMetadata {
|
||||
constructor(public hostPropertyName?: string) {}
|
||||
}
|
||||
|
@ -1125,8 +1125,8 @@ export class HostBindingMetadata {
|
|||
*
|
||||
* bootstrap(App);
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class HostListenerMetadata {
|
||||
constructor(public eventName: string, public args?: string[]) {}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ export var VIEW_ENCAPSULATION_VALUES =
|
|||
* }
|
||||
* }
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class ViewMetadata {
|
||||
/**
|
||||
* Specifies a template URL for an Angular component.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Type, isBlank, isPresent, assertionsEnabled} from 'angular2/src/facade/lang';
|
||||
import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
|
||||
import {Type} from 'angular2/src/facade/lang';
|
||||
import {Provider} from 'angular2/src/core/di';
|
||||
import {Console} from 'angular2/src/core/console';
|
||||
import {Reflector, reflector} from './reflection/reflection';
|
||||
import {ReflectorReader} from './reflection/reflector_reader';
|
||||
|
|
|
@ -76,20 +76,20 @@ function _document(): any {
|
|||
* Used automatically by `bootstrap`, or can be passed to {@link PlatformRef.application}.
|
||||
*/
|
||||
export const BROWSER_APP_COMMON_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/ [
|
||||
/*@ts2dart_const*/[
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
FORM_PROVIDERS,
|
||||
/*@ts2dart_Provider*/{provide: PLATFORM_PIPES, useValue: COMMON_PIPES, multi: true},
|
||||
/*@ts2dart_Provider*/{provide: PLATFORM_DIRECTIVES, useValue: COMMON_DIRECTIVES, multi: true},
|
||||
/*@ts2dart_Provider*/{provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []},
|
||||
/*@ts2dart_Provider*/{provide: DOCUMENT, useFactory: _document, deps: []},
|
||||
/*@ts2dart_Provider*/{provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true},
|
||||
/*@ts2dart_Provider*/{provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true},
|
||||
/*@ts2dart_Provider*/{provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true},
|
||||
/*@ts2dart_Provider*/{provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig},
|
||||
/*@ts2dart_Provider*/{provide: DomRootRenderer, useClass: DomRootRenderer_},
|
||||
/*@ts2dart_Provider*/{provide: RootRenderer, useExisting: DomRootRenderer},
|
||||
/*@ts2dart_Provider*/{provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
/* @ts2dart_Provider */ {provide: PLATFORM_PIPES, useValue: COMMON_PIPES, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: PLATFORM_DIRECTIVES, useValue: COMMON_DIRECTIVES, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []},
|
||||
/* @ts2dart_Provider */ {provide: DOCUMENT, useFactory: _document, deps: []},
|
||||
/* @ts2dart_Provider */ {provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig},
|
||||
/* @ts2dart_Provider */ {provide: DomRootRenderer, useClass: DomRootRenderer_},
|
||||
/* @ts2dart_Provider */ {provide: RootRenderer, useExisting: DomRootRenderer},
|
||||
/* @ts2dart_Provider */ {provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
DomSharedStylesHost,
|
||||
Testability,
|
||||
BrowserDetails,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {assertionsEnabled, isPresent} from 'angular2/src/facade/lang';
|
||||
import {Injectable, provide} from 'angular2/src/core/di';
|
||||
import {assertionsEnabled} from 'angular2/src/facade/lang';
|
||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||
import {DebugNode, getDebugNode} from 'angular2/src/core/debug/debug_node';
|
||||
import {DomRootRenderer} from 'angular2/src/platform/dom/dom_renderer';
|
||||
|
|
|
@ -22,8 +22,8 @@ let _postMessage = {
|
|||
export const WORKER_APP_APPLICATION: Array<any /*Type | Provider | any[]*/> = [
|
||||
WORKER_APP_APPLICATION_COMMON,
|
||||
COMPILER_PROVIDERS,
|
||||
new Provider(MessageBus, {useFactory: createMessageBus, deps: [NgZone]}),
|
||||
new Provider(APP_INITIALIZER, {useValue: setupWebWorker, multi: true})
|
||||
/* @ts2dart_Provider */ {provide: MessageBus, useFactory: createMessageBus, deps: [NgZone]},
|
||||
/* @ts2dart_Provider */ {provide: APP_INITIALIZER, useValue: setupWebWorker, multi: true}
|
||||
];
|
||||
|
||||
function createMessageBus(zone: NgZone): MessageBus {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {XHR} from 'angular2/src/compiler/xhr';
|
||||
import {WebWorkerXHRImpl} from 'angular2/src/web_workers/worker/xhr_impl';
|
||||
import {WebWorkerRootRenderer} from 'angular2/src/web_workers/worker/renderer';
|
||||
import {print, Type, isPresent} from 'angular2/src/facade/lang';
|
||||
import {print} from 'angular2/src/facade/lang';
|
||||
import {RootRenderer} from 'angular2/src/core/render/api';
|
||||
import {
|
||||
PLATFORM_DIRECTIVES,
|
||||
|
@ -22,7 +22,6 @@ import {
|
|||
} from 'angular2/src/web_workers/shared/service_message_broker';
|
||||
import {Serializer} from "angular2/src/web_workers/shared/serializer";
|
||||
import {ON_WEB_WORKER} from "angular2/src/web_workers/shared/api";
|
||||
import {Provider} from 'angular2/src/core/di';
|
||||
import {RenderStore} from 'angular2/src/web_workers/shared/render_store';
|
||||
|
||||
class PrintLogger {
|
||||
|
@ -35,25 +34,31 @@ class PrintLogger {
|
|||
export const WORKER_APP_PLATFORM_MARKER =
|
||||
/*@ts2dart_const*/ new OpaqueToken('WorkerAppPlatformMarker');
|
||||
|
||||
export const WORKER_APP_PLATFORM: Array<any /*Type | Provider | any[]*/> = /*@ts2dart_const*/
|
||||
[PLATFORM_COMMON_PROVIDERS, new Provider(WORKER_APP_PLATFORM_MARKER, {useValue: true})];
|
||||
export const WORKER_APP_PLATFORM: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
/*@ts2dart_const*/ (/* @ts2dart_Provider */ {
|
||||
provide: WORKER_APP_PLATFORM_MARKER,
|
||||
useValue: true
|
||||
})
|
||||
];
|
||||
|
||||
export const WORKER_APP_APPLICATION_COMMON: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
FORM_PROVIDERS,
|
||||
Serializer,
|
||||
new Provider(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
|
||||
new Provider(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
|
||||
new Provider(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}),
|
||||
new Provider(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}),
|
||||
/* @ts2dart_Provider */ {provide: PLATFORM_PIPES, useValue: COMMON_PIPES, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: PLATFORM_DIRECTIVES, useValue: COMMON_DIRECTIVES, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: ClientMessageBrokerFactory, useClass: ClientMessageBrokerFactory_},
|
||||
/* @ts2dart_Provider */ {provide: ServiceMessageBrokerFactory, useClass: ServiceMessageBrokerFactory_},
|
||||
WebWorkerRootRenderer,
|
||||
new Provider(RootRenderer, {useExisting: WebWorkerRootRenderer}),
|
||||
new Provider(ON_WEB_WORKER, {useValue: true}),
|
||||
/* @ts2dart_Provider */ {provide: RootRenderer, useExisting: WebWorkerRootRenderer},
|
||||
/* @ts2dart_Provider */ {provide: ON_WEB_WORKER, useValue: true},
|
||||
RenderStore,
|
||||
new Provider(ExceptionHandler, {useFactory: _exceptionHandler, deps: []}),
|
||||
/* @ts2dart_Provider */ {provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []},
|
||||
WebWorkerXHRImpl,
|
||||
new Provider(XHR, {useExisting: WebWorkerXHRImpl})
|
||||
/* @ts2dart_Provider */ {provide: XHR, useExisting: WebWorkerXHRImpl}
|
||||
];
|
||||
|
||||
function _exceptionHandler(): ExceptionHandler {
|
||||
|
|
|
@ -64,8 +64,8 @@ export const WORKER_RENDER_PLATFORM_MARKER =
|
|||
|
||||
export const WORKER_RENDER_PLATFORM: Array<any /*Type | Provider | any[]*/> = /*@ts2dart_const*/[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
new Provider(WORKER_RENDER_PLATFORM_MARKER, {useValue: true}),
|
||||
new Provider(PLATFORM_INITIALIZER, {useValue: initWebWorkerRenderPlatform, multi: true})
|
||||
/*@ts2dart_const*/ (/* @ts2dart_Provider */ {provide: WORKER_RENDER_PLATFORM_MARKER, useValue: true}),
|
||||
/* @ts2dart_Provider */ {provide: PLATFORM_INITIALIZER, useValue: initWebWorkerRenderPlatform, multi: true}
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -79,23 +79,23 @@ export const WORKER_RENDER_APPLICATION_COMMON: Array<any /*Type | Provider | any
|
|||
/*@ts2dart_const*/[
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
WORKER_RENDER_MESSAGING_PROVIDERS,
|
||||
new Provider(ExceptionHandler, {useFactory: _exceptionHandler, deps: []}),
|
||||
new Provider(DOCUMENT, {useFactory: _document, deps: []}),
|
||||
/* @ts2dart_Provider */ {provide: ExceptionHandler, useFactory: _exceptionHandler, deps: []},
|
||||
/* @ts2dart_Provider */ {provide: DOCUMENT, useFactory: _document, deps: []},
|
||||
// TODO(jteplitz602): Investigate if we definitely need EVENT_MANAGER on the render thread
|
||||
// #5298
|
||||
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}),
|
||||
new Provider(HAMMER_GESTURE_CONFIG, {useClass: HammerGestureConfig}),
|
||||
new Provider(DomRootRenderer, {useClass: DomRootRenderer_}),
|
||||
new Provider(RootRenderer, {useExisting: DomRootRenderer}),
|
||||
new Provider(SharedStylesHost, {useExisting: DomSharedStylesHost}),
|
||||
new Provider(XHR, {useClass: XHRImpl}),
|
||||
/* @ts2dart_Provider */ {provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig},
|
||||
/* @ts2dart_Provider */ {provide: DomRootRenderer, useClass: DomRootRenderer_},
|
||||
/* @ts2dart_Provider */ {provide: RootRenderer, useExisting: DomRootRenderer},
|
||||
/* @ts2dart_Provider */ {provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
||||
/* @ts2dart_Provider */ {provide: XHR, useClass: XHRImpl},
|
||||
MessageBasedXHRImpl,
|
||||
new Provider(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}),
|
||||
new Provider(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}),
|
||||
/* @ts2dart_Provider */ {provide: ServiceMessageBrokerFactory, useClass: ServiceMessageBrokerFactory_},
|
||||
/* @ts2dart_Provider */ {provide: ClientMessageBrokerFactory, useClass: ClientMessageBrokerFactory_},
|
||||
Serializer,
|
||||
new Provider(ON_WEB_WORKER, {useValue: false}),
|
||||
/* @ts2dart_Provider */ {provide: ON_WEB_WORKER, useValue: false},
|
||||
RenderStore,
|
||||
DomSharedStylesHost,
|
||||
Testability,
|
||||
|
|
|
@ -10,8 +10,8 @@ var __make_dart_analyzer_happy: Promise<any> = null;
|
|||
* The `RouteConfig` decorator defines routes for a given component.
|
||||
*
|
||||
* It takes an array of {@link RouteDefinition}s.
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class RouteConfig {
|
||||
constructor(public configs: RouteDefinition[]) {}
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ export abstract class AbstractRoute implements RouteDefinition {
|
|||
* ])
|
||||
* class MyApp {}
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class Route extends AbstractRoute {
|
||||
component: any;
|
||||
aux: string = null;
|
||||
|
@ -94,8 +94,8 @@ export class Route extends AbstractRoute {
|
|||
* ])
|
||||
* class MyApp {}
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class AuxRoute extends AbstractRoute {
|
||||
component: any;
|
||||
|
||||
|
@ -135,8 +135,8 @@ export class AuxRoute extends AbstractRoute {
|
|||
* ])
|
||||
* class MyApp {}
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class AsyncRoute extends AbstractRoute {
|
||||
loader: () => Promise<Type>;
|
||||
aux: string = null;
|
||||
|
@ -174,8 +174,8 @@ export class AsyncRoute extends AbstractRoute {
|
|||
* ])
|
||||
* class MyApp {}
|
||||
* ```
|
||||
* @ts2dart_const
|
||||
*/
|
||||
/* @ts2dart_const */
|
||||
export class Redirect extends AbstractRoute {
|
||||
redirectTo: any[];
|
||||
|
||||
|
|
|
@ -31,7 +31,10 @@ import {PlatformLocation} from 'angular2/platform/common';
|
|||
*/
|
||||
export const ROUTER_PROVIDERS: any[] = /*@ts2dart_const*/[
|
||||
ROUTER_PROVIDERS_COMMON,
|
||||
new Provider(PlatformLocation, {useClass: BrowserPlatformLocation}),
|
||||
/*@ts2dart_const*/ (/* @ts2dart_Provider */ {
|
||||
provide: PlatformLocation,
|
||||
useClass: BrowserPlatformLocation
|
||||
}),
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,15 +10,18 @@ import {BaseException} from 'angular2/src/facade/exceptions';
|
|||
*/
|
||||
export const ROUTER_PROVIDERS_COMMON: any[] = /*@ts2dart_const*/[
|
||||
RouteRegistry,
|
||||
new Provider(LocationStrategy, {useClass: PathLocationStrategy}),
|
||||
/* @ts2dart_Provider */ {provide: LocationStrategy, useClass: PathLocationStrategy},
|
||||
Location,
|
||||
new Provider(Router,
|
||||
{
|
||||
useFactory: routerFactory,
|
||||
deps: [RouteRegistry, Location, ROUTER_PRIMARY_COMPONENT, ApplicationRef]
|
||||
}),
|
||||
new Provider(ROUTER_PRIMARY_COMPONENT,
|
||||
{useFactory: routerPrimaryComponentFactory, deps: [ApplicationRef]})
|
||||
{
|
||||
provide: Router,
|
||||
useFactory: routerFactory,
|
||||
deps: [RouteRegistry, Location, ROUTER_PRIMARY_COMPONENT, ApplicationRef]
|
||||
},
|
||||
{
|
||||
provide: ROUTER_PRIMARY_COMPONENT,
|
||||
useFactory: routerPrimaryComponentFactory,
|
||||
deps: /*@ts2dart_const*/ ([ApplicationRef])
|
||||
}
|
||||
];
|
||||
|
||||
function routerFactory(registry: RouteRegistry, location: Location, primaryComponent: Type,
|
||||
|
|
|
@ -7,7 +7,7 @@ import {APP_INITIALIZER, Provider, Injector, NgZone} from 'angular2/core';
|
|||
export const WORKER_RENDER_ROUTER = /*@ts2dart_const*/[
|
||||
MessageBasedPlatformLocation,
|
||||
BrowserPlatformLocation,
|
||||
new Provider(APP_INITIALIZER, {useFactory: initRouterListeners, multi: true, deps: [Injector]})
|
||||
/* @ts2dart_Provider */ {provide: APP_INITIALIZER, useFactory: initRouterListeners, multi: true, deps: [Injector]}
|
||||
];
|
||||
|
||||
function initRouterListeners(injector: Injector): () => void {
|
||||
|
|
|
@ -5,14 +5,14 @@ import {ROUTER_PROVIDERS_COMMON} from 'angular2/src/router/router_providers_comm
|
|||
|
||||
export var WORKER_APP_ROUTER = [
|
||||
ROUTER_PROVIDERS_COMMON,
|
||||
new Provider(PlatformLocation, {useClass: WebWorkerPlatformLocation}),
|
||||
new Provider(APP_INITIALIZER,
|
||||
{
|
||||
useFactory: (platformLocation: WebWorkerPlatformLocation, zone: NgZone) => () =>
|
||||
initRouter(platformLocation, zone),
|
||||
multi: true,
|
||||
deps: [PlatformLocation, NgZone]
|
||||
})
|
||||
/* @ts2dart_Provider */ {provide: PlatformLocation, useClass: WebWorkerPlatformLocation},
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: (platformLocation: WebWorkerPlatformLocation, zone: NgZone) => () =>
|
||||
initRouter(platformLocation, zone),
|
||||
multi: true,
|
||||
deps: [PlatformLocation, NgZone]
|
||||
}
|
||||
];
|
||||
|
||||
function initRouter(platformLocation: WebWorkerPlatformLocation, zone: NgZone): Promise<boolean> {
|
||||
|
|
|
@ -1371,7 +1371,13 @@ function loginIsEmptyGroupValidator(c: ControlGroup) {
|
|||
|
||||
@Directive({
|
||||
selector: '[login-is-empty-validator]',
|
||||
providers: [new Provider(NG_VALIDATORS, {useValue: loginIsEmptyGroupValidator, multi: true})]
|
||||
providers: [
|
||||
/* @ts2dart_Provider */ {
|
||||
provide: NG_VALIDATORS,
|
||||
useValue: loginIsEmptyGroupValidator,
|
||||
multi: true
|
||||
}
|
||||
]
|
||||
})
|
||||
class LoginIsEmptyValidator {
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import {print, IS_DART} from 'angular2/src/facade/lang';
|
||||
import {TypeScriptEmitter} from 'angular2/src/compiler/output/ts_emitter';
|
||||
import {DartEmitter} from 'angular2/src/compiler/output/dart_emitter';
|
||||
import * as o from 'angular2/src/compiler/output/output_ast';
|
||||
import {compileComp, compAMetadata} from './offline_compiler_util';
|
||||
import {ComponentFactory} from 'angular2/src/core/linker/component_factory';
|
||||
|
||||
|
|
|
@ -254,8 +254,8 @@ export function main() {
|
|||
it('should support multiProviders', () => {
|
||||
var injector = createInjector([
|
||||
Engine,
|
||||
new Provider(Car, {useClass: SportsCar, multi: true}),
|
||||
new Provider(Car, {useClass: CarWithOptionalEngine, multi: true})
|
||||
/* @ts2dart_Provider */ {provide: Car, useClass: SportsCar, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: Car, useClass: CarWithOptionalEngine, multi: true}
|
||||
]);
|
||||
|
||||
var cars = injector.get(Car);
|
||||
|
@ -264,14 +264,15 @@ export function main() {
|
|||
expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine);
|
||||
});
|
||||
|
||||
it('should support multiProviders that are created using useExisting', () => {
|
||||
var injector = createInjector(
|
||||
[Engine, SportsCar, new Provider(Car, {useExisting: SportsCar, multi: true})]);
|
||||
it('should support multiProviders that are created using useExisting',
|
||||
() => {
|
||||
var injector = createInjector(
|
||||
[Engine, SportsCar, /* @ts2dart_Provider */ {provide: Car, useExisting: SportsCar, multi: true}]);
|
||||
|
||||
var cars = injector.get(Car);
|
||||
expect(cars.length).toEqual(1);
|
||||
expect(cars[0]).toBe(injector.get(SportsCar));
|
||||
});
|
||||
var cars = injector.get(Car);
|
||||
expect(cars.length).toEqual(1);
|
||||
expect(cars[0]).toBe(injector.get(SportsCar));
|
||||
});
|
||||
|
||||
it('should throw when the aliased provider does not exist', () => {
|
||||
var injector = createInjector([provide('car', {useExisting: SportsCar})]);
|
||||
|
@ -523,8 +524,8 @@ export function main() {
|
|||
|
||||
it("should support multi providers", () => {
|
||||
var provider = ReflectiveInjector.resolve([
|
||||
new Provider(Engine, {useClass: BrokenEngine, multi: true}),
|
||||
new Provider(Engine, {useClass: TurboEngine, multi: true})
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: TurboEngine, multi: true}
|
||||
])[0];
|
||||
|
||||
expect(provider.key.token).toBe(Engine);
|
||||
|
@ -535,8 +536,8 @@ export function main() {
|
|||
|
||||
it("should support providers as hash", () => {
|
||||
var provider = ReflectiveInjector.resolve([
|
||||
{provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
{provide: Engine, useClass: TurboEngine, multi: true}
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: BrokenEngine, multi: true},
|
||||
/* @ts2dart_Provider */ {provide: Engine, useClass: TurboEngine, multi: true}
|
||||
])[0];
|
||||
|
||||
expect(provider.key.token).toBe(Engine);
|
||||
|
@ -545,25 +546,41 @@ export function main() {
|
|||
});
|
||||
|
||||
it("should support multi providers with only one provider", () => {
|
||||
var provider = ReflectiveInjector.resolve(
|
||||
[new Provider(Engine, {useClass: BrokenEngine, multi: true})])[0];
|
||||
var provider = ReflectiveInjector.resolve([
|
||||
/* @ts2dart_Provider */ {
|
||||
provide: Engine,
|
||||
useClass: BrokenEngine,
|
||||
multi: true
|
||||
}
|
||||
])[0];
|
||||
|
||||
expect(provider.key.token).toBe(Engine);
|
||||
expect(provider.multiProvider).toEqual(true);
|
||||
expect(provider.resolvedFactories.length).toEqual(1);
|
||||
});
|
||||
|
||||
it("should throw when mixing multi providers with regular providers", () => {
|
||||
expect(() => {
|
||||
ReflectiveInjector.resolve(
|
||||
[new Provider(Engine, {useClass: BrokenEngine, multi: true}), Engine]);
|
||||
}).toThrowErrorWith("Cannot mix multi providers and regular providers");
|
||||
it("should throw when mixing multi providers with regular providers",
|
||||
() => {
|
||||
expect(() => {
|
||||
ReflectiveInjector.resolve([
|
||||
/* @ts2dart_Provider */ {
|
||||
provide: Engine,
|
||||
useClass: BrokenEngine,
|
||||
multi: true
|
||||
},
|
||||
Engine
|
||||
]);
|
||||
})
|
||||
.toThrowErrorWith(
|
||||
"Cannot mix multi providers and regular providers");
|
||||
|
||||
expect(() => {
|
||||
ReflectiveInjector.resolve(
|
||||
[Engine, new Provider(Engine, {useClass: BrokenEngine, multi: true})]);
|
||||
}).toThrowErrorWith("Cannot mix multi providers and regular providers");
|
||||
});
|
||||
expect(() => {
|
||||
ReflectiveInjector.resolve(
|
||||
[Engine, /* @ts2dart_Provider */ {provide: Engine, useClass: BrokenEngine, multi: true}]);
|
||||
})
|
||||
.toThrowErrorWith(
|
||||
"Cannot mix multi providers and regular providers");
|
||||
});
|
||||
|
||||
it('should resolve forward references', () => {
|
||||
var providers = ReflectiveInjector.resolve([
|
||||
|
|
|
@ -2272,7 +2272,13 @@ class PublicApi {
|
|||
|
||||
@Directive({
|
||||
selector: '[public-api]',
|
||||
providers: [new Provider(PublicApi, {useExisting: PrivateImpl, deps: []})]
|
||||
providers: [
|
||||
/* @ts2dart_Provider */ {
|
||||
provide: PublicApi,
|
||||
useExisting: PrivateImpl,
|
||||
deps: []
|
||||
}
|
||||
]
|
||||
})
|
||||
@Injectable()
|
||||
class PrivateImpl extends PublicApi {
|
||||
|
@ -2343,7 +2349,11 @@ function createInjectableWithLogging(inj: Injector) {
|
|||
@Component({
|
||||
selector: 'component-providing-logging-injectable',
|
||||
providers: [
|
||||
new Provider(InjectableService, {useFactory: createInjectableWithLogging, deps: [Injector]})
|
||||
/* @ts2dart_Provider */ {
|
||||
provide: InjectableService,
|
||||
useFactory: createInjectableWithLogging,
|
||||
deps: [Injector]
|
||||
}
|
||||
],
|
||||
template: ''
|
||||
})
|
||||
|
@ -2369,8 +2379,10 @@ class DirectiveProvidingInjectableInView {
|
|||
|
||||
@Component({
|
||||
selector: 'directive-providing-injectable',
|
||||
providers: [new Provider(InjectableService, {useValue: 'host'})],
|
||||
viewProviders: [new Provider(InjectableService, {useValue: 'view'})],
|
||||
providers:
|
||||
[/* @ts2dart_Provider */ {provide: InjectableService, useValue: 'host'}],
|
||||
viewProviders:
|
||||
[/* @ts2dart_Provider */ {provide: InjectableService, useValue: 'view'}],
|
||||
template: ''
|
||||
})
|
||||
@Injectable()
|
||||
|
@ -2420,7 +2432,12 @@ class EventBus {
|
|||
|
||||
@Directive({
|
||||
selector: 'grand-parent-providing-event-bus',
|
||||
providers: [new Provider(EventBus, {useValue: new EventBus(null, "grandparent")})]
|
||||
providers: [
|
||||
/* @ts2dart_Provider */ {
|
||||
provide: EventBus,
|
||||
useValue: new EventBus(null, "grandparent")
|
||||
}
|
||||
]
|
||||
})
|
||||
class GrandParentProvidingEventBus {
|
||||
bus: EventBus;
|
||||
|
|
|
@ -4,6 +4,6 @@ import {HashLocationStrategy, LocationStrategy} from 'angular2/platform/common';
|
|||
import {App} from "./index_common";
|
||||
|
||||
export function main() {
|
||||
bootstrapApp(
|
||||
App, [WORKER_APP_ROUTER, new Provider(LocationStrategy, {useClass: HashLocationStrategy})]);
|
||||
bootstrapApp(App,
|
||||
[WORKER_APP_ROUTER, {provide: LocationStrategy, useClass: HashLocationStrategy}]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue