mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
docs(modal): remove navParams usage
This commit is contained in:
@ -40,23 +40,21 @@ export class ModalExample {
|
||||
|
||||
```typescript
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { NavParams } from '@ionic/angular';
|
||||
|
||||
@Component({
|
||||
selector: 'modal-page',
|
||||
})
|
||||
export class ModalPage {
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
### Passing Data
|
||||
|
||||
During creation of a modal, data can be passed in through the `componentProps`. The previous example can be written to include data:
|
||||
During creation of a modal, data can be passed in through the `componentProps`.
|
||||
The previous example can be written to include data:
|
||||
|
||||
```typescript
|
||||
async presentModal() {
|
||||
@ -72,7 +70,7 @@ async presentModal() {
|
||||
}
|
||||
```
|
||||
|
||||
To get the data passed into the `componentProps`, either set it as an `@Input` or access it via `NavParams` on the `ModalPage`:
|
||||
To get the data passed into the `componentProps`, set it as an `@Input`:
|
||||
|
||||
```typescript
|
||||
export class ModalPage {
|
||||
@ -82,11 +80,6 @@ export class ModalPage {
|
||||
@Input() lastName: string;
|
||||
@Input() middleInitial: string;
|
||||
|
||||
constructor(navParams: NavParams) {
|
||||
// componentProps can also be accessed at construction time using NavParams
|
||||
console.log(navParams.get('firstName'));
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -24,23 +24,21 @@ export class ModalExample {
|
||||
|
||||
```typescript
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { NavParams } from '@ionic/angular';
|
||||
|
||||
@Component({
|
||||
selector: 'modal-page',
|
||||
})
|
||||
export class ModalPage {
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
### Passing Data
|
||||
|
||||
During creation of a modal, data can be passed in through the `componentProps`. The previous example can be written to include data:
|
||||
During creation of a modal, data can be passed in through the `componentProps`.
|
||||
The previous example can be written to include data:
|
||||
|
||||
```typescript
|
||||
async presentModal() {
|
||||
@ -56,7 +54,7 @@ async presentModal() {
|
||||
}
|
||||
```
|
||||
|
||||
To get the data passed into the `componentProps`, either set it as an `@Input` or access it via `NavParams` on the `ModalPage`:
|
||||
To get the data passed into the `componentProps`, set it as an `@Input`:
|
||||
|
||||
```typescript
|
||||
export class ModalPage {
|
||||
@ -66,11 +64,6 @@ export class ModalPage {
|
||||
@Input() lastName: string;
|
||||
@Input() middleInitial: string;
|
||||
|
||||
constructor(navParams: NavParams) {
|
||||
// componentProps can also be accessed at construction time using NavParams
|
||||
console.log(navParams.get('firstName'));
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user