File tree Expand file tree Collapse file tree 6 files changed +141
-0
lines changed
Expand file tree Collapse file tree 6 files changed +141
-0
lines changed Original file line number Diff line number Diff line change 1+ html , body {
2+ background : # CCCCCC ;
3+ }
Original file line number Diff line number Diff line change 1+ <!--The content below is only a placeholder and can be replaced.-->
2+ < div class ="container ">
3+ < h1 align ="center ">
4+ Welcome to {{ title }}!
5+ </ h1 >
6+
7+
8+ < div class ="col-md-2 ">
9+ < button type ="button "
10+ class ="btn btn-success btn-block "
11+ modal-box
12+ [title] ='"Demo Modal 1" '
13+ [componentData] ="data1 "
14+ [componentName] ="'Demo1Component' ">
15+ Demo Modal 1
16+ </ button >
17+ </ div >
18+
19+ < div class ="col-md-2 ">
20+ < button type ="button "
21+ class ="btn btn-danger btn-block "
22+ modal-box
23+ [title] ='"Demo Modal 2" '
24+ [componentData] ="data2 "
25+ [componentName] ="'Demo2Component' ">
26+ Demo Modal 2
27+ </ button >
28+ </ div >
29+
30+
31+ </ div >
32+
33+
Original file line number Diff line number Diff line change 1+ import { TestBed , async } from '@angular/core/testing' ;
2+ import { AppComponent } from './app.component' ;
3+ describe ( 'AppComponent' , ( ) => {
4+ beforeEach ( async ( ( ) => {
5+ TestBed . configureTestingModule ( {
6+ declarations : [
7+ AppComponent
8+ ] ,
9+ } ) . compileComponents ( ) ;
10+ } ) ) ;
11+ it ( 'should create the app' , async ( ( ) => {
12+ const fixture = TestBed . createComponent ( AppComponent ) ;
13+ const app = fixture . debugElement . componentInstance ;
14+ expect ( app ) . toBeTruthy ( ) ;
15+ } ) ) ;
16+ it ( `should have as title 'app'` , async ( ( ) => {
17+ const fixture = TestBed . createComponent ( AppComponent ) ;
18+ const app = fixture . debugElement . componentInstance ;
19+ expect ( app . title ) . toEqual ( 'app' ) ;
20+ } ) ) ;
21+ it ( 'should render title in a h1 tag' , async ( ( ) => {
22+ const fixture = TestBed . createComponent ( AppComponent ) ;
23+ fixture . detectChanges ( ) ;
24+ const compiled = fixture . debugElement . nativeElement ;
25+ expect ( compiled . querySelector ( 'h1' ) . textContent ) . toContain ( 'Welcome to myapp!' ) ;
26+ } ) ) ;
27+ } ) ;
Original file line number Diff line number Diff line change 1+ import { Component } from '@angular/core' ;
2+ import { Demo1Component } from './demo1/demo1.component' ;
3+
4+ @Component ( {
5+ selector : 'app-root' ,
6+ templateUrl : './app.component.html' ,
7+ styleUrls : [ './app.component.css' ]
8+ } )
9+ export class AppComponent {
10+ data1 : string ;
11+ data2 : string ;
12+
13+
14+ ngOnInit ( ) {
15+ this . data1 = "The content is displayed from Demo1 component" ;
16+ this . data2 = "The content is displayed from Demo2 component" ;
17+ }
18+
19+ }
Original file line number Diff line number Diff line change 1+ import { BrowserModule } from '@angular/platform-browser' ;
2+ import { NgModule } from '@angular/core' ;
3+ import { HttpClientModule } from '@angular/common/http' ;
4+
5+ import { AppComponent } from './app.component' ;
6+ import { Demo1Component } from './demo1/demo1.component' ;
7+ import { Demo2Component } from './demo2/demo2.component' ;
8+ import { ModalDialogComponent } from './modal-dialog/modal-dialog.component' ;
9+ import { ModalDirective } from './modal.directive' ;
10+ import { DatacontainerDirective } from './modal-dialog/datacontainer.directive' ;
11+ import { ComponentLoaderService } from './component-loader.service' ;
12+
13+ //import { ModalDialogDirective } from './modal-dialog/modal-dialog.directive';
14+
15+ @NgModule ( {
16+ declarations : [
17+ AppComponent ,
18+ Demo1Component ,
19+ Demo2Component ,
20+ ModalDialogComponent ,
21+ ModalDirective ,
22+ DatacontainerDirective
23+ ] ,
24+ providers : [ ComponentLoaderService ] ,
25+ imports : [
26+ BrowserModule ,
27+ HttpClientModule
28+ ] ,
29+ entryComponents : [
30+ Demo1Component ,
31+ Demo2Component ,
32+ ModalDialogComponent
33+ ] ,
34+ bootstrap : [ AppComponent ]
35+ } )
36+ export class AppModule { }
Original file line number Diff line number Diff line change 1+ import { Injectable } from '@angular/core' ;
2+ import { Demo1Component } from './demo1/demo1.component' ;
3+ import { Demo2Component } from './demo2/demo2.component' ;
4+
5+ @Injectable ( {
6+ providedIn : 'root'
7+ } )
8+ export class ComponentLoaderService {
9+
10+ constructor ( ) { }
11+
12+ getComponent ( componentName : string ) {
13+ if ( componentName == "Demo2Component" ) {
14+ return Demo2Component ;
15+ }
16+ else if ( componentName == "Demo1Component" ) {
17+ return Demo1Component ;
18+ }
19+ else {
20+ return "" ;
21+ }
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments