Guest User

Untitled

a guest
Feb 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. @Component({
  2. selector: 'my-app',
  3. template: `
  4. <div class="container-fluid">
  5. <div class="page-header">
  6. <h1>Creating AOT Friendly Dynamic Components with Angular 2</h1>
  7. </div>
  8. <div class="row">
  9. <div class="col-lg-12">
  10. <div class="panel panel-default">
  11. <div class="panel-heading">Application Code</div>
  12. <div class="panel-body">
  13. <div class="input-group">
  14. <span class="input-group-btn">
  15. <button type="button" class="btn btn-primary" (click)="grid.addDynamicCellComponent(selectedComponentType)">Add Dynamic Grid component</button>
  16. </span>
  17. <select class="form-control" [(ngModel)]="selectedComponentType">
  18. <option *ngFor="let cellComponentType of componentTypes" [ngValue]="cellComponentType">{{cellComponentType.name}}</option>
  19. </select>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="row">
  26. <div class="col-lg-12">
  27. <div class="panel panel-default">
  28. <div class="panel-heading">Library Code</div>
  29. <div class="panel-body">
  30. <grid-component #grid></grid-component>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. `
  37. })
  38. export class AppComponent implements OnInit {
  39. @Input() componentTypes: any[] = [BlueDynamicComponent, GreenDynamicComponent, RedDynamicComponent];
  40. @Input() selectedComponentType: any;
  41. ngOnInit(): void {
  42. // default to the first available option
  43. this.selectedComponentType = this.componentTypes ? this.componentTypes[0] : null;
  44. }
  45. }
Add Comment
Please, Sign In to add comment