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
409cb122
Commit
409cb122
authored
Jan 24, 2017
by
avovchuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix demo app
parent
8ac3d533
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
18 deletions
+31
-18
demo/package.json
demo/package.json
+1
-1
demo/src/app/app.component.spec.ts
demo/src/app/app.component.spec.ts
+13
-8
demo/src/app/app.component.ts
demo/src/app/app.component.ts
+17
-9
No files found.
demo/package.json
View file @
409cb122
...
...
@@ -22,7 +22,7 @@
"@angular/platform-browser-dynamic"
:
"^2.4.3"
,
"@angular/router"
:
"^3.3.1"
,
"core-js"
:
"^2.4.1"
,
"ng2-bootstrap-modal"
:
"
git+https://github.com/ankosoftware/ng2-bootstrap-modal.git
"
,
"ng2-bootstrap-modal"
:
"
^0.0.1
"
,
"rxjs"
:
"^5.0.1"
,
"ts-helpers"
:
"^1.1.1"
,
"zone.js"
:
"^0.7.2"
...
...
demo/src/app/app.component.spec.ts
View file @
409cb122
/* tslint:disable:no-unused-variable */
import
{
TestBed
,
async
}
from
'
@angular/core/testing
'
;
import
{
AppModule
}
from
'
./app.module
'
;
import
{
AppComponent
}
from
'
./app.component
'
;
describe
(
'
AppComponent
'
,
()
=>
{
beforeEach
(()
=>
{
TestBed
.
configureTestingModule
({
declaration
s
:
[
App
Component
import
s
:
[
App
Module
],
});
TestBed
.
compileComponents
();
...
...
@@ -19,16 +20,20 @@ describe('AppComponent', () => {
expect
(
app
).
toBeTruthy
();
}));
it
(
`should have as title 'app works!'`
,
async
(()
=>
{
it
(
'
should render button "Show confirm"
'
,
async
(()
=>
{
const
fixture
=
TestBed
.
createComponent
(
AppComponent
);
const
app
=
fixture
.
debugElement
.
componentInstance
;
expect
(
app
.
title
).
toEqual
(
'
app works!
'
);
fixture
.
detectChanges
();
const
compiled
=
fixture
.
debugElement
.
nativeElement
;
expect
(
compiled
.
querySelector
(
'
button
'
).
textContent
).
toContain
(
'
Show confirm
'
);
}));
it
(
'
should render title in a h1 tag
'
,
async
(()
=>
{
//FIXME:Uncaught Error: Error in ./AppComponent class AppComponent - inline template:3:10 caused by: Cannot read property 'hostView' of undefined
/*it('should render confirm dialog by click', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect
(
compiled
.
querySelector
(
'
h1
'
).
textContent
).
toContain
(
'
app works!
'
);
}));
compiled.querySelector('button').click();
expect(compiled.querySelector('.modal')).toBeDefined();
}));*/
});
demo/src/app/app.component.ts
View file @
409cb122
import
{
Component
}
from
'
@angular/core
'
;
import
{
ConfirmComponent
}
from
'
./confirm.component
'
;
import
{
DialogService
}
from
"
ng2-bootstrap-modal
"
;
import
Timer
=
NodeJS
.
Timer
;
@
Component
({
selector
:
'
app
'
,
template
:
`
<div class="container">
<button class="btn btn-default" (click)=showConfirm()>Show confirm</button>
<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>
`
})
export
class
AppComponent
{
confirmResult
:
boolean
=
null
;
timeoutId
:
Timer
;
constructor
(
private
dialogService
:
DialogService
)
{}
showConfirm
()
{
let
disposable
=
this
.
dialogService
.
addDialog
(
ConfirmComponent
,
{
...
...
@@ -18,17 +23,20 @@ export class AppComponent {
message
:
'
Confirm message
'
})
.
subscribe
((
isConfirmed
)
=>
{
//We get dialog result
if
(
isConfirmed
)
{
alert
(
'
accepted
'
);
}
else
{
alert
(
'
declined
'
);
}
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
setTimeout
(()
=>
{
this
.
timeoutId
=
setTimeout
(()
=>
{
disposable
.
unsubscribe
();
this
.
confirmResult
=
null
;
},
10000
);
}
}
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