feat(PrivateComponentLoader): Explicit error message when loading a non-component
fixes #1062
This commit is contained in:
@ -2,8 +2,9 @@ import {Compiler} from './compiler';
|
||||
import {ShadowDomStrategy} from './shadow_dom_strategy';
|
||||
import {EventManager} from 'angular2/src/core/events/event_manager';
|
||||
import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader';
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
import {PrivateComponentLocation} from './private_component_location';
|
||||
import {Type} from 'angular2/src/facade/lang';
|
||||
import {Type, stringify, BaseException} from 'angular2/src/facade/lang';
|
||||
|
||||
|
||||
export class PrivateComponentLoader {
|
||||
@ -23,6 +24,11 @@ export class PrivateComponentLoader {
|
||||
|
||||
load(type:Type, location:PrivateComponentLocation) {
|
||||
var annotation = this.directiveMetadataReader.read(type).annotation;
|
||||
|
||||
if (!(annotation instanceof Component)) {
|
||||
throw new BaseException(`Could not load '${stringify(type)}' because it is not a component.`);
|
||||
}
|
||||
|
||||
return this.compiler.compile(type).then((componentProtoView) => {
|
||||
location.createComponent(
|
||||
type, annotation,
|
||||
|
Reference in New Issue
Block a user