-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(window): window may return result (#2869)
- Loading branch information
1 parent
e8fa95b
commit 95247a4
Showing
8 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/playground/with-layout/window/components/visitors-form.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { Component } from '@angular/core'; | ||
import { FormBuilder, FormGroup } from '@angular/forms'; | ||
import { NbWindowRef } from '@nebular/theme'; | ||
|
||
@Component({ | ||
template: ` | ||
<form [formGroup]="form" (ngSubmit)="onSubmit()" class="form"> | ||
<label for="name">Enter your name:</label> | ||
<input nbInput id="name" type="text" formControlName="name" /> | ||
<button nbButton type="submit" status="success">Submit</button> | ||
</form> | ||
`, | ||
}) | ||
export class VisitorsFormComponent { | ||
form: FormGroup; | ||
|
||
constructor(private fb: FormBuilder, public windowRef: NbWindowRef) { | ||
this.form = fb.group({ | ||
name: null, | ||
}); | ||
} | ||
|
||
onSubmit() { | ||
this.windowRef.close(this.form.value.name); | ||
} | ||
|
||
close() { | ||
this.windowRef.close(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/playground/with-layout/window/window-result.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { Component } from '@angular/core'; | ||
import { NbWindowService } from '@nebular/theme'; | ||
import { VisitorsFormComponent } from './components/visitors-form.component'; | ||
|
||
@Component({ | ||
template: ` | ||
<button nbButton status="primary" (click)="openWindow()">Open window</button> | ||
<br /> | ||
<h3 class="h5">Window visitors:</h3> | ||
<ul> | ||
<li *ngFor="let visitor of visitors">{{ visitor }}</li> | ||
</ul> | ||
`, | ||
styleUrls: ['./window.scss'], | ||
}) | ||
export class WindowResultComponent { | ||
visitors: string[] = []; | ||
|
||
constructor(private windowService: NbWindowService) {} | ||
|
||
openWindow() { | ||
const windowRef = this.windowService.open(VisitorsFormComponent, { title: `Window` }); | ||
|
||
windowRef.onClose.subscribe((visitor) => this.visitors.push(visitor)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,10 @@ | |
.text-label { | ||
margin-top: 1.5rem; | ||
} | ||
|
||
button { | ||
margin-top: 1.5rem; | ||
} | ||
} | ||
|
||
button + button { | ||
|