mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
docs(): update angular usage
This commit is contained in:
12
core/src/components.d.ts
vendored
12
core/src/components.d.ts
vendored
@ -164,6 +164,9 @@ declare global {
|
|||||||
* Title for the action sheet.
|
* Title for the action sheet.
|
||||||
*/
|
*/
|
||||||
'header': string;
|
'header': string;
|
||||||
|
/**
|
||||||
|
* If the actionSheet should close the keyboard
|
||||||
|
*/
|
||||||
'keyboardClose': boolean;
|
'keyboardClose': boolean;
|
||||||
/**
|
/**
|
||||||
* Animation to use when the action sheet is dismissed.
|
* Animation to use when the action sheet is dismissed.
|
||||||
@ -177,6 +180,9 @@ declare global {
|
|||||||
* Returns a promise that resolves when the action-sheet will dismiss. It also accepts a callback that is called in the same circustances. ``` const {data, role} = await actionSheet.onWillDismiss(); ```
|
* Returns a promise that resolves when the action-sheet will dismiss. It also accepts a callback that is called in the same circustances. ``` const {data, role} = await actionSheet.onWillDismiss(); ```
|
||||||
*/
|
*/
|
||||||
'onWillDismiss': (callback?: ((detail: OverlayEventDetail) => void) | undefined) => Promise<OverlayEventDetail>;
|
'onWillDismiss': (callback?: ((detail: OverlayEventDetail) => void) | undefined) => Promise<OverlayEventDetail>;
|
||||||
|
/**
|
||||||
|
* Unique ID to be used with the overlay. Internal only
|
||||||
|
*/
|
||||||
'overlayId': number;
|
'overlayId': number;
|
||||||
/**
|
/**
|
||||||
* Present the action sheet overlay after it has been created.
|
* Present the action sheet overlay after it has been created.
|
||||||
@ -236,6 +242,9 @@ declare global {
|
|||||||
* Title for the action sheet.
|
* Title for the action sheet.
|
||||||
*/
|
*/
|
||||||
'header'?: string;
|
'header'?: string;
|
||||||
|
/**
|
||||||
|
* If the actionSheet should close the keyboard
|
||||||
|
*/
|
||||||
'keyboardClose'?: boolean;
|
'keyboardClose'?: boolean;
|
||||||
/**
|
/**
|
||||||
* Animation to use when the action sheet is dismissed.
|
* Animation to use when the action sheet is dismissed.
|
||||||
@ -265,6 +274,9 @@ declare global {
|
|||||||
* Emitted before the alert has presented.
|
* Emitted before the alert has presented.
|
||||||
*/
|
*/
|
||||||
'onIonActionSheetWillPresent'?: (event: CustomEvent<void>) => void;
|
'onIonActionSheetWillPresent'?: (event: CustomEvent<void>) => void;
|
||||||
|
/**
|
||||||
|
* Unique ID to be used with the overlay. Internal only
|
||||||
|
*/
|
||||||
'overlayId'?: number;
|
'overlayId'?: number;
|
||||||
/**
|
/**
|
||||||
* Subtitle for the action sheet.
|
* Subtitle for the action sheet.
|
||||||
|
|||||||
@ -30,7 +30,15 @@ export class ActionSheet implements OverlayInterface {
|
|||||||
|
|
||||||
@Prop({ connect: 'ion-animation-controller' }) animationCtrl!: HTMLIonAnimationControllerElement;
|
@Prop({ connect: 'ion-animation-controller' }) animationCtrl!: HTMLIonAnimationControllerElement;
|
||||||
@Prop({ context: 'config' }) config!: Config;
|
@Prop({ context: 'config' }) config!: Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique ID to be used with the overlay. Internal only
|
||||||
|
*/
|
||||||
@Prop() overlayId!: number;
|
@Prop() overlayId!: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the actionSheet should close the keyboard
|
||||||
|
*/
|
||||||
@Prop() keyboardClose = true;
|
@Prop() keyboardClose = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -56,6 +56,8 @@ Title for the action sheet.
|
|||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
|
||||||
|
If the actionSheet should close the keyboard
|
||||||
|
|
||||||
|
|
||||||
#### leaveAnimation
|
#### leaveAnimation
|
||||||
|
|
||||||
@ -68,6 +70,8 @@ Animation to use when the action sheet is dismissed.
|
|||||||
|
|
||||||
number
|
number
|
||||||
|
|
||||||
|
Unique ID to be used with the overlay. Internal only
|
||||||
|
|
||||||
|
|
||||||
#### subHeader
|
#### subHeader
|
||||||
|
|
||||||
@ -132,6 +136,8 @@ Title for the action sheet.
|
|||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
|
||||||
|
If the actionSheet should close the keyboard
|
||||||
|
|
||||||
|
|
||||||
#### leave-animation
|
#### leave-animation
|
||||||
|
|
||||||
@ -144,6 +150,8 @@ Animation to use when the action sheet is dismissed.
|
|||||||
|
|
||||||
number
|
number
|
||||||
|
|
||||||
|
Unique ID to be used with the overlay. Internal only
|
||||||
|
|
||||||
|
|
||||||
#### sub-header
|
#### sub-header
|
||||||
|
|
||||||
|
|||||||
@ -11,8 +11,8 @@ export class ActionSheetExample {
|
|||||||
|
|
||||||
constructor(public actionSheetController: ActionSheetController) {}
|
constructor(public actionSheetController: ActionSheetController) {}
|
||||||
|
|
||||||
presentActionSheet() {
|
async presentActionSheet() {
|
||||||
const actionSheet = this.actionSheetController.create({
|
const actionSheet = await this.actionSheetController.create({
|
||||||
header: "Albums",
|
header: "Albums",
|
||||||
buttons: [{
|
buttons: [{
|
||||||
text: 'Delete',
|
text: 'Delete',
|
||||||
@ -48,8 +48,7 @@ export class ActionSheetExample {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
await actionSheet.present();
|
||||||
actionSheet.present();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,30 +11,30 @@ export class AlertExample {
|
|||||||
|
|
||||||
constructor(public alertController: AlertController) {}
|
constructor(public alertController: AlertController) {}
|
||||||
|
|
||||||
presentAlert() {
|
async presentAlert() {
|
||||||
const alert = this.alertController.create({
|
const alert = await this.alertController.create({
|
||||||
header: 'Alert',
|
header: 'Alert',
|
||||||
subHeader: 'Subtitle',
|
subHeader: 'Subtitle',
|
||||||
message: 'This is an alert message.',
|
message: 'This is an alert message.',
|
||||||
buttons: ['OK']
|
buttons: ['OK']
|
||||||
});
|
});
|
||||||
|
|
||||||
alert.present();
|
await alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
presentAlertMultipleButtons() {
|
async presentAlertMultipleButtons() {
|
||||||
const alert = this.alertController.create({
|
const alert = await this.alertController.create({
|
||||||
header: 'Alert',
|
header: 'Alert',
|
||||||
subHeader: 'Subtitle',
|
subHeader: 'Subtitle',
|
||||||
message: 'This is an alert message.',
|
message: 'This is an alert message.',
|
||||||
buttons: ['Cancel', 'Open Modal', 'Delete']
|
buttons: ['Cancel', 'Open Modal', 'Delete']
|
||||||
});
|
});
|
||||||
|
|
||||||
alert.present();
|
await alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
presentAlertConfirm() {
|
async presentAlertConfirm() {
|
||||||
const alert = this.alertController.create({
|
const alert = await this.alertController.create({
|
||||||
header: 'Confirm!',
|
header: 'Confirm!',
|
||||||
message: 'Message <strong>text</strong>!!!',
|
message: 'Message <strong>text</strong>!!!',
|
||||||
buttons: [
|
buttons: [
|
||||||
@ -54,11 +54,11 @@ export class AlertExample {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
alert.present();
|
await alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
presentAlertPrompt() {
|
async presentAlertPrompt() {
|
||||||
const alert = this.alertController.create({
|
const alert = await this.alertController.create({
|
||||||
header: 'Prompt!',
|
header: 'Prompt!',
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
@ -116,11 +116,11 @@ export class AlertExample {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
alert.present();
|
await alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
presentAlertRadio() {
|
async presentAlertRadio() {
|
||||||
const alert = this.alertController.create({
|
const alert = await this.alertController.create({
|
||||||
header: 'Radio',
|
header: 'Radio',
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
@ -172,11 +172,11 @@ export class AlertExample {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
alert.present();
|
await alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
presentAlertCheckbox() {
|
async presentAlertCheckbox() {
|
||||||
const alert = this.alertController.create({
|
const alert = await this.alertController.create({
|
||||||
header: 'Checkbox',
|
header: 'Checkbox',
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
@ -233,7 +233,7 @@ export class AlertExample {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
alert.present();
|
await alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,30 +5,28 @@ import { LoadingController } from '@ionic/angular';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'loading-example',
|
selector: 'loading-example',
|
||||||
templateUrl: 'loading-example.html',
|
templateUrl: 'loading-example.html',
|
||||||
styleUrls: ['./loading-example.css'],
|
styleUrls: ['./loading-example.css']
|
||||||
})
|
})
|
||||||
export class LoadingExample {
|
export class LoadingExample {
|
||||||
|
|
||||||
constructor(public loadingController: LoadingController) {}
|
constructor(public loadingController: LoadingController) {}
|
||||||
|
|
||||||
presentLoading() {
|
async presentLoading() {
|
||||||
const loading = this.loadingController.create({
|
const loading = await this.loadingController.create({
|
||||||
message: 'Hellooo',
|
message: 'Hellooo',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
loading.present();
|
return await loading.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
presentLoadingWithOptions() {
|
presentLoadingWithOptions() {
|
||||||
const loading = this.loadingController.create({
|
const loading = await this.loadingController.create({
|
||||||
spinner: 'hide',
|
spinner: 'hide',
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
content: 'Please wait...',
|
content: 'Please wait...',
|
||||||
translucent: true,
|
translucent: true,
|
||||||
cssClass: 'custom-class custom-loading'
|
cssClass: 'custom-class custom-loading'
|
||||||
});
|
});
|
||||||
loading.present();
|
return await loading.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@ -8,40 +8,6 @@ A Modal is a dialog that appears on top of the app's content, and must be dismis
|
|||||||
Modals can be created using a [Modal Controller](../../modal-controller/ModalController). They can be customized by passing modal options in the modal controller's create method.
|
Modals can be created using a [Modal Controller](../../modal-controller/ModalController). They can be customized by passing modal options in the modal controller's create method.
|
||||||
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
async function presentModal() {
|
|
||||||
// initialize controller
|
|
||||||
const modalController = document.querySelector('ion-modal-controller');
|
|
||||||
await modalController.componentOnReady();
|
|
||||||
|
|
||||||
// create component to open
|
|
||||||
const element = document.createElement('div');
|
|
||||||
element.innerHTML = `
|
|
||||||
<ion-header>
|
|
||||||
<ion-toolbar>
|
|
||||||
<ion-title>Super Modal</ion-title>
|
|
||||||
</ion-toolbar>
|
|
||||||
</ion-header>
|
|
||||||
<ion-content>
|
|
||||||
<h1>Content of doom</h1>
|
|
||||||
<div>Here's some more content</div>
|
|
||||||
<ion-button class="dismiss">Dismiss Modal</ion-button>
|
|
||||||
</ion-content>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// listen for close event
|
|
||||||
const button = element.querySelector('ion-button');
|
|
||||||
button.addEventListener('click', () => {
|
|
||||||
modalController.dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
// present the modal
|
|
||||||
const modalElement = await modalController.create({
|
|
||||||
component: element
|
|
||||||
});
|
|
||||||
modalElement.present();
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
<!-- Auto Generated Below -->
|
<!-- Auto Generated Below -->
|
||||||
|
|
||||||
|
|||||||
21
core/src/components/modal/usage/angular.md
Normal file
21
core/src/components/modal/usage/angular.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
```typescript
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { ModalController } from '@ionic/angular';
|
||||||
|
import { ModalPage } from '../modal/modal.page';
|
||||||
|
@Component({
|
||||||
|
selector: 'modal-example',
|
||||||
|
templateUrl: 'modal-example.html',
|
||||||
|
styleUrls: ['./modal-example.css']
|
||||||
|
})
|
||||||
|
export class ModalExample {
|
||||||
|
constructor(public modalController: ModalController) {}
|
||||||
|
|
||||||
|
async presentModal() {
|
||||||
|
const modal = await this.modalController.create({
|
||||||
|
component: ModalPage,
|
||||||
|
componentProps: { value: 123 }
|
||||||
|
});
|
||||||
|
return await modal.present();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
34
core/src/components/modal/usage/javascript.md
Normal file
34
core/src/components/modal/usage/javascript.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
```javascript
|
||||||
|
async function presentModal() {
|
||||||
|
// initialize controller
|
||||||
|
const modalController = document.querySelector('ion-modal-controller');
|
||||||
|
await modalController.componentOnReady();
|
||||||
|
|
||||||
|
// create component to open
|
||||||
|
const element = document.createElement('div');
|
||||||
|
element.innerHTML = `
|
||||||
|
<ion-header>
|
||||||
|
<ion-toolbar>
|
||||||
|
<ion-title>Super Modal</ion-title>
|
||||||
|
</ion-toolbar>
|
||||||
|
</ion-header>
|
||||||
|
<ion-content>
|
||||||
|
<h1>Content of doom</h1>
|
||||||
|
<div>Here's some more content</div>
|
||||||
|
<ion-button class="dismiss">Dismiss Modal</ion-button>
|
||||||
|
</ion-content>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// listen for close event
|
||||||
|
const button = element.querySelector('ion-button');
|
||||||
|
button.addEventListener('click', () => {
|
||||||
|
modalController.dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
// present the modal
|
||||||
|
const modalElement = await modalController.create({
|
||||||
|
component: element
|
||||||
|
});
|
||||||
|
modalElement.present();
|
||||||
|
}
|
||||||
|
```
|
||||||
@ -1,24 +1,23 @@
|
|||||||
```typescript
|
```typescript
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { PopoverController } from '@ionic/angular';
|
import { PopoverController } from '@ionic/angular';
|
||||||
|
import { PopoverComponent } from '../../component/popover/popover.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'popover-example',
|
selector: 'popover-example',
|
||||||
templateUrl: 'popover-example.html',
|
templateUrl: 'popover-example.html',
|
||||||
styleUrls: ['./popover-example.css'],
|
styleUrls: ['./popover-example.css']
|
||||||
})
|
})
|
||||||
export class PopoverExample {
|
export class PopoverExample {
|
||||||
|
|
||||||
constructor(public popoverController: PopoverController) {}
|
constructor(public popoverController: PopoverController) {}
|
||||||
|
|
||||||
presentPopover(ev: any) {
|
async presentPopover(ev: any) {
|
||||||
const popover = this.popoverController.create({
|
const popover = await this.popoverController.create({
|
||||||
component: 'popover-example-page',
|
component: PopoverComponent,
|
||||||
ev: event,
|
ev: event,
|
||||||
translucent: true
|
translucent: true
|
||||||
});
|
});
|
||||||
popover.present();
|
return await popover.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user