Skip to content

Commit 13cf1aa

Browse files
DevTools button
1 parent 7a719d3 commit 13cf1aa

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/app/app.component.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@
77
.links {
88
font-family: sans-serif;
99
}
10+
11+
.dev-tools {
12+
background: #DD0031;
13+
border-color: #C3002F;
14+
margin-top: 11px;
15+
padding: 6px 9px;
16+
color: #FFF;
17+
font-family: Verdana, Tahoma, sans-serif;
18+
font-size: 18px;
19+
}

src/app/app.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ <h1>
77
<div>
88
{{ versions }}
99
</div>
10+
<button
11+
*ngIf="isDev"
12+
class="dev-tools"
13+
(click)="openDevTools($event)"
14+
>
15+
Open Dev Tools
16+
</button>
1017
</div>
1118

1219
<div class="links">

src/app/app.component.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ import { Component } from '@angular/core';
88

99
export class AppComponent {
1010
title = 'nw-angular';
11+
isDev = window.nw.process.versions['nw-flavor'] === 'sdk';
1112

1213
versions = '' +
13-
'You are running NW.js (v' + window.nw.process.versions.nw + '), ' +
14+
'You are running NW.js (v' + window.nw.process.versions.nw + ' ' + window.nw.process.versions['nw-flavor'] + '), ' +
1415
'Node.js (v' + window.nw.process.versions.node + '), ' +
1516
'Chromium (v' + window.nw.process.versions.chromium + '), ' +
16-
'and Angular 8.';
17+
'and Angular (v8.0.3).';
1718

1819
public links: any;
1920

20-
constructor() {
21+
constructor () {
2122
this.links = [
2223
{
2324
title: 'Angular Tutorial',
@@ -34,8 +35,13 @@ export class AppComponent {
3435
]
3536
}
3637

37-
public open(evt, link) {
38+
public open (evt, link) {
3839
evt.preventDefault();
3940
window.nw.Shell.openExternal(link.url);
4041
}
42+
43+
public openDevTools (evt) {
44+
evt.preventDefault();
45+
window.nw.Window.get().showDevTools();
46+
}
4147
}

0 commit comments

Comments
 (0)