Skip to content

Commit e8e803d

Browse files
authored
Merge pull request #379 from NativeScript/niliev/modal
docs: modal page article improvements
2 parents a8c2c03 + 9b8dd41 commit e8e803d

File tree

11 files changed

+50
-35
lines changed

11 files changed

+50
-35
lines changed

app/app.module.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
// this import should be first in order to load some required settings (like globals and reflect-metadata)
21
// >> ngmodule-config
3-
// >> (hide)
2+
// this import should be first in order to load some required settings (like globals and reflect-metadata)
43
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
54
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
65
import { NativeScriptRouterModule } from "nativescript-angular/router";
76
import { NativeScriptFormsModule } from "nativescript-angular/forms";
8-
97
import { routes } from "./app.routes";
108
import { AppComponent } from "./app.component";
11-
// << (hide)
129
import { ModalDialogService } from "nativescript-angular/modal-dialog";
1310

1411
@NgModule({
@@ -27,5 +24,6 @@ import { ModalDialogService } from "nativescript-angular/modal-dialog";
2724
ModalDialogService,
2825
]
2926
})
30-
// << ngmodule-config
27+
3128
export class AppModule { }
29+
// << ngmodule-config
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
Modal Dialog with ActionBar
1+
The following example is demonstrating how to create a modal page with `ActionBar`. The **_main-view.component_** is the page from which, you will open the root modal (**_modal-root.component_**). The root modal contains a `page-router-outlet` and has a default navigation to **_modal-view.component_** while using the children routing configuration.
22

3-
Defining the main page component
3+
**_main-view.component.html_** and **_main-view.component.ts_**
44
<snippet id='main-view-html'/>
55
<snippet id='main-view-code'/>
66

7-
Definig modal view innner component's routes
8-
7+
Routing configuration file (**_modal-view-examples.module.ts_**) which sets the children routes (in this example the `modal-view` path).
98
<snippet id='modal-view-routes-actionbar'/>
109

11-
Defining the modal root component
10+
**_modal-root.component.html_** and **_modal-root.component.ts_** contains `page-router-outlet` with default navigation via `modal-view` path.
1211
<snippet id='modal-root-html'/>
1312
<snippet id='modal-root-code'/>
1413

15-
Defining the modal view component with an ActionBar
14+
**_modal-view.component.html_** and **_modal-view.component.ts_** (the default `modal-view` path). The modal contains `ActionBar`.
1615
<snippet id='modal-view-actionbar-html'/>
17-
<snippet id='modal-view-actionbar-code'/>
16+
<snippet id='modal-view-actionbar-code'/>

app/ng-ui-category/modal-view-ng/modal-view-actionbar/main-view.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!-- >> main-view-html -->
2+
<!-- main-view.component.html -->
23
<StackLayout class="page" sdkExampleTitle sdkToggleNavButton>
34
<Button text="SHOW MODAL" (tap)="onTap()"></Button>
45
</StackLayout>

app/ng-ui-category/modal-view-ng/modal-view-actionbar/main-view.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
// >> main-view-code
2+
// main-view.component.ts
13
import { Component, OnInit, ViewContainerRef } from "@angular/core";
24
import { ModalDialogOptions, ModalDialogService } from "nativescript-angular/modal-dialog";
3-
45
import { ModalRootComponent } from "./modal-root.component";
56

67
@Component({
@@ -14,7 +15,7 @@ export class MainViewComponent implements OnInit {
1415
private _vcRef: ViewContainerRef) { }
1516

1617
ngOnInit(): void { }
17-
// >> main-view-code
18+
1819
onTap(): void {
1920
const options: ModalDialogOptions = {
2021
viewContainerRef: this._vcRef,
@@ -27,5 +28,5 @@ export class MainViewComponent implements OnInit {
2728
console.log(result);
2829
});
2930
}
30-
// << main-view-code
3131
}
32+
// << main-view-code

app/ng-ui-category/modal-view-ng/modal-view-navigation/article.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
Modal Dialog Navigation
1+
The following example demonstrates how to enable navigaiton within a modal page. First we have a component which opens the main root modal. The root modal contains a `page-router-outlet` which has a default navigaiton via the `modal` route (loads the **_home-modal-view-content.component_**). The router outlet has its own routing table (**_modal-view-examples.module.ts_**) and can navigate to the `second-modal` route within the root modal.
22

3-
@NgModule config
3+
Providing the `ModalDialogService` in `@NgModule` config.
4+
**_app.module.ts_**
45
<snippet id='ngmodule-config'/>
56

6-
Defining the `page-router-outlet` for the modal view's main component and navigating to the first inner modal view
7+
The component (**_modal-view-navigation.component_**) which opens the root modal view (**_home-modal-view.component_**).
78

8-
<snippet id='main-modal-view'/>
9-
<snippet id='main-modal-view-code'/>
10-
11-
Definig modal view innner component's routes
9+
**_modal-view-navigation.component.html_** and **_modal-view-navigation.component.ts**
10+
<snippet id='opening-modal-view-html'/>
11+
<snippet id='opening-modal-view'/>
1212

13+
Routing configuration file (**_modal-view-examples.module.ts_**) which sets the children routes (in this example the `modal` and `second-modal` path).
1314
<snippet id='modal-view-routes'/>
1415

15-
Defining the first inner modal view
16+
The root modal component contains the `page-router-outlet` and has a default navigation to the first inner modal view.
17+
18+
**_home-modal-view.component.html_** and **_home-modal-view.component.ts_**
19+
<snippet id='main-modal-view'/>
20+
<snippet id='main-modal-view-code'/>
1621

22+
Defining the first inner modal view (the `modal` route).
23+
24+
**_home-modal-view-content.component.html_** and **_home-modal-view-content.component.ts_**
1725
<snippet id='first-modal-view'/>
1826
<snippet id='first-modal-view-code'/>
1927

20-
> NB: We can navigate to the second component inside the Modal view while defining its relative path(e.g. `"../second-modal"`). To navigate relatively, we should use ActiveRouter module as it is demonstrated in the example above.
28+
> **Note:** We can navigate to the second component inside the Modal view while defining its relative path(e.g. `"../second-modal"`). To navigate relatively, we should use ActiveRouter module as it is demonstrated in the example above.
2129
22-
Defining the second inner modal view
30+
Defining the first inner modal view (the `second-modal` route).
2331

32+
**_second-modal-view-content.component.html_** and **_second-modal-view-content.component.ts_**
2433
<snippet id='second-modal-view'/>
2534
<snippet id='second-modal-view-code'/>
2635

27-
Opening the modal view
28-
29-
<snippet id='opening-modal-view'/>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
<!-- >> opening-modal-view-html -->
13
<StackLayout class="page" sdkExampleTitle sdkToggleNavButton>
24
<Button text="SHOW MODAL" (tap)="onTap()"></Button>
35
</StackLayout>
6+
<!-- << opening-modal-view-html -->

app/ng-ui-category/modal-view-ng/modal-view-navigation/modal-view-navigation.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// >> opening-modal-view
1+
// >> opening-modal-view
22
import { Component, ViewContainerRef } from "@angular/core";
33
import { ModalDialogOptions, ModalDialogService } from "nativescript-angular/modal-dialog";
44
import { HomeModalViewComponent } from "./home-modal-view.component";
@@ -23,5 +23,5 @@ export class ModalViewNavigationComponent {
2323
console.log(result);
2424
});
2525
}
26-
// << opening-modal-view
2726
}
27+
// << opening-modal-view
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
Modal Dialog
22

3-
@NgModule config
3+
**_app.module.ts_**
44
<snippet id='ngmodule-config'/>
55

6-
Add `modal-dialog-host`
6+
The host component (**_sample-modal-view-module.example.html_**) from which we will open the different modal pages (e.g., **_modal-view.html_**).
7+
8+
**_sample-modal-view-module.example.html_**
79
<snippet id='add-modal-dialog-host'/>
810

9-
Passing parameters
11+
Passing parameters from the opened modal view.
12+
13+
**_modal-view.html_** and **_modal-view.ts_**
14+
<snippet id='passing-parameters-html'/>
1015
<snippet id='passing-parameters'/>
1116

12-
Returning a result
17+
Receiving the result from the modal page.
1318
<snippet id='returning-result'/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
<!-- >> passing-parameters-html -->
12
<StackLayout class="modal-view-style" sdkExampleTitle sdkToggleNavButton>
23
<DatePicker #datepicker></DatePicker>
34
<Button class="btn btn-primary btn-active" text="Submit" (tap)="submit()"></Button>
45
</StackLayout>
6+
<!-- >> passing-parameters-html -->

app/ng-ui-category/modal-view-ng/sample-modal-view-module-example/sample-modal-view-module-example.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<Label [text]='"Days: " + days' class="m-15" textWrap="true"></Label>
1313
<Button class="btn btn-primary btn-active" text="Count Days" (tap)="countDays()"></Button>
1414

15-
1615
<Label text='Use different date formats' class="m-15 h2" textWrap="true"></Label>
1716

1817
<Label [text]='"Date: " + (selectedDate | date: "MM/dd/yy")' class="m-15" textWrap="true"></Label>

app/ng-ui-category/modal-view-ng/sample-modal-view-module-example/sample-modal-view-module-example.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class SampleModalViewModuleExampleComponent {
5454
fullscreen: false,
5555
};
5656

57+
// showModal returns a promise with the received paramerters from the modal page
5758
return this.modalService.showModal(ModalViewComponent, options);
5859
}
5960
// << returning-result

0 commit comments

Comments
 (0)