@@ -2,7 +2,10 @@ import {
22 bootstrap ,
33 Component ,
44 Decorator ,
5- View
5+ View ,
6+ DynamicComponentLoader ,
7+ ElementRef ,
8+ DynamicComponent
69} from 'angular2/angular2' ;
710import { LifeCycle } from 'angular2/src/core/life_cycle/life_cycle' ;
811import { List , ListWrapper } from 'angular2/src/facade/collection' ;
@@ -39,12 +42,18 @@ export function main() {
3942 app . createComponentsWithDecorators ( ) ;
4043 lifeCycle . tick ( ) ;
4144 } ) ;
45+
46+ // Components with decorators
47+ bindAction ( '#createDynamicComponents' , function ( ) {
48+ app . createDynamicComponents ( ) ;
49+ lifeCycle . tick ( ) ;
50+ } ) ;
4251 } ) ;
4352}
4453
4554@Component ( { selector : 'app' } )
4655@View ( {
47- directives : [ If , For , DummyComponent , DummyDecorator ] ,
56+ directives : [ If , For , DummyComponent , DummyDecorator , DynamicDummy ] ,
4857 template : `
4958 <div *if="testingPlainComponents">
5059 <dummy *for="#i of list"></dummy>
@@ -53,12 +62,17 @@ export function main() {
5362 <div *if="testingWithDecorators">
5463 <dummy dummy-decorator *for="#i of list"></dummy>
5564 </div>
65+
66+ <div *if="testingDynamicComponents">
67+ <dynamic-dummy *for="#i of list"></dynamic-dummy>
68+ </div>
5669 `
5770} )
5871class AppComponent {
5972 list :List ;
6073 testingPlainComponents :boolean ;
6174 testingWithDecorators :boolean ;
75+ testingDynamicComponents :boolean ;
6276
6377 constructor ( ) {
6478 this . reset ( ) ;
@@ -68,6 +82,7 @@ class AppComponent {
6882 this . list = [ ] ;
6983 this . testingPlainComponents = false ;
7084 this . testingWithDecorators = false ;
85+ this . testingDynamicComponents = false ;
7186 }
7287
7388 createPlainComponents ( ) :void {
@@ -79,6 +94,11 @@ class AppComponent {
7994 this . list = testList ;
8095 this . testingWithDecorators = true ;
8196 }
97+
98+ createDynamicComponents ( ) :void {
99+ this . list = testList ;
100+ this . testingDynamicComponents = true ;
101+ }
82102}
83103
84104@Component ( { selector : 'dummy' } )
@@ -87,3 +107,10 @@ class DummyComponent {}
87107
88108@Decorator ( { selector : '[dummy-decorator]' } )
89109class DummyDecorator { }
110+
111+ @DynamicComponent ( { selector : 'dynamic-dummy' } )
112+ class DynamicDummy {
113+ constructor ( loader :DynamicComponentLoader , location :ElementRef ) {
114+ loader . loadIntoExistingLocation ( DummyComponent , location ) ;
115+ }
116+ }
0 commit comments