feat(core): introduce @AppModule

Main part for #9726
Closes #9730
This commit is contained in:
Tobias Bosch
2016-06-28 09:54:42 -07:00
parent 1608d91728
commit 17e4cfc748
52 changed files with 2085 additions and 851 deletions

View File

@ -6,16 +6,27 @@
* found in the LICENSE file at https://angular.io/license
*/
import {unimplemented} from '../facade/exceptions';
import {BaseException, unimplemented} from '../facade/exceptions';
import {stringify} from '../facade/lang';
const _THROW_IF_NOT_FOUND = /*@ts2dart_const*/ new Object();
export const THROW_IF_NOT_FOUND = /*@ts2dart_const*/ _THROW_IF_NOT_FOUND;
class _NullInjector implements Injector {
get(token: any, notFoundValue: any = _THROW_IF_NOT_FOUND): any {
if (notFoundValue === _THROW_IF_NOT_FOUND) {
throw new BaseException(`No provider for ${stringify(token)}!`);
}
return notFoundValue;
}
}
/**
* @stable
*/
export abstract class Injector {
static THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
static NULL: Injector = new _NullInjector();
/**
* Retrieves an instance from the injector based on the provided token.