@@ -12,12 +12,14 @@ export class DemoModalServiceFromComponent {
12
12
13
13
openModalWithComponent ( ) {
14
14
const initialState : ModalOptions = {
15
+ container : 'bs-demo' ,
15
16
initialState : {
16
17
list : [
17
18
'Open a modal with component' ,
18
19
'Pass your data' ,
19
20
'Do something else' ,
20
- '...'
21
+ '...' ,
22
+ 'Push button to find out!'
21
23
] ,
22
24
title : 'Modal with component'
23
25
}
@@ -32,6 +34,7 @@ export class DemoModalServiceFromComponent {
32
34
@Component ( {
33
35
// eslint-disable-next-line @angular-eslint/component-selector
34
36
selector : 'modal-content' ,
37
+ styleUrls : [ './service-component.css' ] ,
35
38
template : `
36
39
<div class="modal-header">
37
40
<h4 class="modal-title pull-left">{{title}}</h4>
@@ -41,23 +44,27 @@ export class DemoModalServiceFromComponent {
41
44
</div>
42
45
<div class="modal-body">
43
46
<ul *ngIf="list.length">
44
- <li *ngFor="let item of list">{{item}}</li>
47
+ <li *ngFor="let item of list" [ngClass]="{ 'profit' : item === 'PROFIT!!!'}" >{{item}}</li>
45
48
</ul>
46
49
</div>
47
50
<div class="modal-footer">
51
+ <button *ngIf="!profitBtnPressed" type="button" class="btn btn-default" (click)="showProfit()">Find Out</button>
48
52
<button type="button" class="btn btn-default" (click)="bsModalRef.hide()">{{closeBtnName}}</button>
49
53
</div>
50
54
`
51
55
} )
52
56
53
- export class ModalContentComponent implements OnInit {
57
+ export class ModalContentComponent {
54
58
title ?: string ;
59
+ profitBtnPressed : boolean = false ;
55
60
closeBtnName ?: string ;
56
61
list : any [ ] = [ ] ;
57
62
58
63
constructor ( public bsModalRef : BsModalRef ) { }
59
64
60
- ngOnInit ( ) {
61
- this . list . push ( 'PROFIT!!!' ) ;
65
+ showProfit ( ) {
66
+ this . profitBtnPressed = true ;
67
+ this . list [ this . list . length - 1 ] = 'PROFIT!!!' ;
62
68
}
69
+
63
70
}
0 commit comments