Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Ng2 Bootstrap Modal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Globars Forks
Ng2 Bootstrap Modal
Commits
0b84bc78
Commit
0b84bc78
authored
Jan 25, 2017
by
avovchuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more demo examples
parent
962b254f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
121 additions
and
25 deletions
+121
-25
demo/src/app/alert.component.ts
demo/src/app/alert.component.ts
+23
-0
demo/src/app/app.component.html
demo/src/app/app.component.html
+38
-0
demo/src/app/app.component.ts
demo/src/app/app.component.ts
+20
-23
demo/src/app/app.module.ts
demo/src/app/app.module.ts
+10
-2
demo/src/app/confirm.component.ts
demo/src/app/confirm.component.ts
+1
-0
demo/src/app/prompt.component.ts
demo/src/app/prompt.component.ts
+29
-0
No files found.
demo/src/app/alert.component.ts
0 → 100644
View file @
0b84bc78
import
{
Component
}
from
'
@angular/core
'
;
import
{
DialogComponent
,
DialogService
}
from
"
ng2-bootstrap-modal
"
;
@
Component
({
selector
:
'
alert
'
,
template
:
`<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" (click)="close()" >×</button>
<h4 class="modal-title">{{title || 'Alert'}}</h4>
</div>
<div class="modal-body">
<p>{{message || '!!!'}}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)="close()">OK</button>
</div>
</div>`
})
export
class
AlertComponent
extends
DialogComponent
{
constructor
(
dialogService
:
DialogService
)
{
super
(
dialogService
);
}
}
demo/src/app/app.component.html
0 → 100644
View file @
0b84bc78
<div
class=
"container"
>
<h1
class=
"text-center"
>
ng2-bootstrap-modal demo application
</h1>
<div
class=
"row"
>
<div
class=
"col-sm-4 text-right"
>
<b>
Alert example:
</b>
</div>
<div
class=
"col-sm-4"
>
<button
class=
"btn btn-default btn-block"
(click)=
showAlert()
>
Show alert
</button>
</div>
</div>
<br><br>
<div
class=
"row"
>
<div
class=
"col-sm-4 text-right"
>
<b>
Confirm example:
</b>
</div>
<div
class=
"col-sm-4"
>
<button
class=
"btn btn-default btn-block"
(click)=
showConfirm()
>
Show confirm
</button>
</div>
<div
class=
"col-sm-4"
>
<span>
Result:
</span>
<b
*ngIf=
"confirmResult == null"
class=
"text-default"
>
Not answered
</b>
<b
*ngIf=
"confirmResult != null"
[ngClass]=
"{'text-danger': !confirmResult, 'text-success': confirmResult}"
>
{{confirmResult ? 'Accepted': 'Declined'}}
</b>
</div>
</div>
<br><br>
<div
class=
"row"
>
<div
class=
"col-sm-4 text-right"
>
<b>
Prompt example:
</b>
</div>
<div
class=
"col-sm-4"
>
<button
class=
"btn btn-default btn-block"
(click)=
showPrompt()
>
Show prompt
</button>
</div>
<div
class=
"col-sm-4"
>
<span>
Your name:
</span>
<b>
{{promptMessage}}
</b>
</div>
</div>
</div>
demo/src/app/app.component.ts
View file @
0b84bc78
import
{
Component
}
from
'
@angular/core
'
;
import
{
AlertComponent
}
from
'
./alert.component
'
;
import
{
ConfirmComponent
}
from
'
./confirm.component
'
;
import
{
PromptComponent
}
from
'
./prompt.component
'
;
import
{
DialogService
}
from
"
ng2-bootstrap-modal
"
;
import
Timer
=
NodeJS
.
Timer
;
@
Component
({
selector
:
'
app
'
,
template
:
`
<div class="container" >
<h1>ng2-bootstrap-modal demo application</h1>
<button class="btn btn-default" (click)=showConfirm()>Show confirm</button>
<span>Result: <b>{{ confirmResult }}</b></span>
</div>
`
templateUrl
:
'
./app.component.html
'
})
export
class
AppComponent
{
confirmResult
:
boolean
=
null
;
timeoutId
:
Timer
;
promptMessage
:
string
=
''
;
constructor
(
private
dialogService
:
DialogService
)
{}
showAlert
()
{
this
.
dialogService
.
addDialog
(
AlertComponent
,
{
title
:
'
Alert!!!!
'
,
message
:
'
TADAM!!!
'
});
}
showConfirm
()
{
let
disposable
=
this
.
dialogService
.
addDialog
(
ConfirmComponent
,
{
title
:
'
Confirm
title
'
,
message
:
'
Confirm message
'
})
title
:
'
Confirm
ation
'
,
message
:
'
Bla bla comfirm action?
'
})
.
subscribe
((
isConfirmed
)
=>
{
//We get dialog result
this
.
confirmResult
=
!!
isConfirmed
;
});
//We can close dialog calling disposable.unsubscribe();
if
(
this
.
timeoutId
)
{
clearTimeout
(
this
.
timeoutId
);
}
//If dialog was not closed manually close it by timeout
this
.
timeoutId
=
setTimeout
(()
=>
{
disposable
.
unsubscribe
();
this
.
confirmResult
=
null
;
},
10000
);
}
showPrompt
()
{
let
disposable
=
this
.
dialogService
.
addDialog
(
PromptComponent
,
{
title
:
'
Name dialog
'
,
question
:
'
Enter your name:
'
})
.
subscribe
((
message
)
=>
{
//We get dialog result
this
.
promptMessage
=
message
;
});
}
}
demo/src/app/app.module.ts
View file @
0b84bc78
...
...
@@ -3,20 +3,28 @@ import { CommonModule } from "@angular/common";
import
{
BrowserModule
}
from
"
@angular/platform-browser
"
;
import
{
BootstrapModalModule
}
from
'
ng2-bootstrap-modal
'
;
import
{
ConfirmComponent
}
from
'
./confirm.component
'
;
import
{
AlertComponent
}
from
'
./alert.component
'
;
import
{
PromptComponent
}
from
'
./prompt.component
'
;
import
{
FormsModule
}
from
'
@angular/forms
'
;
import
{
AppComponent
}
from
'
./app.component
'
;
@
NgModule
({
declarations
:
[
AppComponent
,
ConfirmComponent
AlertComponent
,
ConfirmComponent
,
PromptComponent
],
imports
:
[
CommonModule
,
BrowserModule
,
FormsModule
,
BootstrapModalModule
],
//Don't forget add component to entryComponents section
entryComponents
:
[
ConfirmComponent
AlertComponent
,
ConfirmComponent
,
PromptComponent
],
bootstrap
:
[
AppComponent
]
})
...
...
demo/src/app/confirm.component.ts
View file @
0b84bc78
import
{
Component
}
from
'
@angular/core
'
;
import
{
DialogComponent
,
DialogService
}
from
"
ng2-bootstrap-modal
"
;
@
Component
({
selector
:
'
confirm
'
,
template
:
`<div class="modal-content">
<div class="modal-header">
...
...
demo/src/app/prompt.component.ts
0 → 100644
View file @
0b84bc78
import
{
Component
}
from
'
@angular/core
'
;
import
{
DialogComponent
,
DialogService
}
from
"
ng2-bootstrap-modal
"
;
@
Component
({
selector
:
'
confirm
'
,
template
:
`<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" (click)="close()" >×</button>
<h4 class="modal-title">{{title || 'Prompt'}}</h4>
</div>
<div class="modal-body">
<label>{{question}}</label><input type="text" class="form-control" [(ngModel)]="message" name="name" >
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)="apply()">OK</button>
<button type="button" class="btn btn-default" (click)="close()" >Cancel</button>
</div>
</div>`
})
export
class
PromptComponent
extends
DialogComponent
{
message
:
string
=
''
;
constructor
(
dialogService
:
DialogService
)
{
super
(
dialogService
);
}
apply
()
{
this
.
result
=
this
.
message
;
this
.
close
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment