Skip to content

Commit d300a30

Browse files
authored
Add files via upload
1 parent 9fd4efe commit d300a30

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed

src/app/app.component.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
html,body{
2+
background: #CCCCCC;
3+
}

src/app/app.component.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+

src/app/app.component.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
});

src/app/app.component.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
}

src/app/app.module.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 { }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}

0 commit comments

Comments
 (0)