Skip to content

Commit 42fa823

Browse files
committed
Add view child nativeElement
1 parent 6fa8495 commit 42fa823

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

projects/angular-nodegui/src/lib/components/window.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FlexLayout, QMainWindow } from '@nodegui/nodegui';
1+
import { FlexLayout, QMainWindow, WindowType } from '@nodegui/nodegui';
22
import { NgComponent } from './component';
33
import { RendererStyleFlags2 } from '@angular/core';
44

@@ -17,8 +17,13 @@ export class NgWindow extends FlexLayout implements NgComponent {
1717
value: string,
1818
namespace?: string | null
1919
): void {
20-
if (name === 'title') {
21-
this.parent.setWindowTitle(value);
20+
switch (name) {
21+
case 'title':
22+
this.parent.setWindowTitle(value);
23+
break;
24+
25+
default:
26+
break;
2227
}
2328
}
2429

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<window title="Angular app in window!">
1+
<window #window title="Angular app in window!">
22
<view id="app">
33
<image
44
id="image"

src/app/app.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#app {
2-
background-color: gray;
2+
background-color: gray;
33
}
44

55
#app-hello {

src/app/app.component.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
1-
import { Component, ViewEncapsulation } from '@angular/core';
2-
import { AspectRatioMode } from '@nodegui/nodegui';
1+
import { Component, ViewEncapsulation, ViewChild, OnInit, ElementRef } from '@angular/core';
2+
import { AspectRatioMode, WindowType } from '@nodegui/nodegui';
3+
import { NgWindow } from '../../projects/angular-nodegui/src/lib/components/window';
34

45
@Component({
56
selector: 'app-root',
67
templateUrl: './app.component.html',
78
styleUrls: ['./app.component.scss'],
89
encapsulation: ViewEncapsulation.None
910
})
10-
export class AppComponent {
11+
export class AppComponent implements OnInit {
12+
@ViewChild('window', { static: true}) window: ElementRef<NgWindow>;
13+
1114
public name = 'irustm';
1215
public aspectRatioMode = AspectRatioMode.KeepAspectRatio;
1316

17+
constructor() {
18+
19+
}
20+
21+
ngOnInit() {
22+
const win = this.window.nativeElement.parent;
23+
24+
win.setFixedSize(630, 560);
25+
// win.setWindowFlag(WindowType.FramelessWindowHint, true);
26+
// win.setWindowFlag(WindowType.Widget, true);
27+
}
28+
1429
setName() {
1530
this.name = 'irustm';
1631
}
1732

1833
textChanged(val: string) {
1934
this.name = val;
2035
}
36+
2137
}

0 commit comments

Comments
 (0)