Skip to content

Commit 6230dbb

Browse files
committed
fix(typescript code blocks): typescript -> tsx
1 parent e01ad90 commit 6230dbb

383 files changed

Lines changed: 8443 additions & 9993 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/angular/config.md

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Ionic Config provides a way to change the properties of components globally acro
66

77
To override the initial Ionic config for the app, provide a config in `IonicModule.forRoot` in the `app.module.ts` file.
88

9-
```typescript
9+
```tsx
1010
import { IonicModule } from '@ionic/angular';
1111

1212
@NgModule({
@@ -25,12 +25,11 @@ import { IonicModule } from '@ionic/angular';
2525

2626
In the above example, we are disabling the Material Design ripple effect across the app, as well as forcing the mode to be Material Design.
2727

28-
2928
## Per-Component Config
3029

3130
Ionic Config is not reactive, so it is recommended to use a component's properties when you want to override its default behavior rather than set its config globally.
3231

33-
```typescript
32+
```tsx
3433
import { IonicModule } from '@ionic/angular';
3534

3635
@NgModule({
@@ -60,11 +59,10 @@ Ionic Config can also be set on a per-platform basis. For example, this allows y
6059

6160
Since the config is set at runtime, you will not have access to the Platform Dependency Injection. Instead, you can use the underlying functions that the provider uses directly.
6261

63-
In the following example, we are disabling all animations in our Ionic app only if the app is running in a mobile web browser.
62+
In the following example, we are disabling all animations in our Ionic app only if the app is running in a mobile web browser.
6463
The `isPlatform()` call returns `true` or `false` based upon the platform that is passed in. See the [Platform Documentation](platform.md#platforms) for a list of possible values.
6564

66-
67-
```typescript
65+
```tsx
6866
import { isPlatform, IonicModule } from '@ionic/angular';
6967

7068
@NgModule({
@@ -82,7 +80,7 @@ import { isPlatform, IonicModule } from '@ionic/angular';
8280

8381
The next example allows you to set an entirely different configuration based upon the platform, falling back to a default config if no platforms match:
8482

85-
```typescript
83+
```tsx
8684
import { isPlatform, IonicModule } from '@ionic/angular';
8785

8886
const getConfig = () => {
@@ -92,7 +90,7 @@ const getConfig = () => {
9290
tabButtonLayout: 'label-hide'
9391
}
9492
}
95-
93+
9694
return {
9795
menuIcon: 'ellipsis-vertical'
9896
}
@@ -110,21 +108,21 @@ const getConfig = () => {
110108

111109
Finally, this example allows you to accumulate a config object based upon different platform requirements:
112110

113-
```typescript
111+
```tsx
114112
import { isPlatform, IonicModule } from '@ionic/angular';
115113

116114
const getConfig = () => {
117115
let config = {
118116
animated: false
119117
};
120-
118+
121119
if (isPlatform('iphone')) {
122120
config = {
123121
...config,
124122
backButtonText: 'Previous'
125123
}
126124
}
127-
125+
128126
return config;
129127
}
130128
@NgModule({
@@ -143,35 +141,35 @@ const getConfig = () => {
143141
Below is a list of config options that Ionic uses.
144142

145143
| Config | Type | Description |
146-
|--------------------------|--------------------|----------------------------------------------------------------------------------------------------------|
147-
| `actionSheetEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-action-sheet`, overriding the default "animation".
148-
| `actionSheetLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-action-sheet`, overriding the default "animation".
149-
| `alertEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-alert`, overriding the default "animation".
150-
| `alertLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-alert`, overriding the default "animation".
151-
| `animated` | `boolean` | If `true`, Ionic will enable all animations and transitions across the app.
152-
| `backButtonIcon` | `string` | Overrides the default icon in all `<ion-back-button>` components.
153-
| `backButtonText` | `string` | Overrides the default text in all `<ion-back-button>` components.
154-
| `hardwareBackButton` | `boolean` | If `true`, Ionic will respond to the hardware back button in an Android device.
155-
| `infiniteLoadingSpinner` | `SpinnerTypes` | Overrides the default spinner type in all `<ion-infinite-scroll-content>` components.
156-
| `loadingEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-loading`, overriding the default "animation".
157-
| `loadingLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-loading`, overriding the default "animation".
158-
| `loadingSpinner` | `SpinnerTypes` | Overrides the default spinner for all `ion-loading` overlays.
159-
| `menuIcon` | `string` | Overrides the default icon in all `<ion-menu-button>` components.
160-
| `menuType` | `string` | Overrides the default menu type for all `<ion-menu>` components.
161-
| `modalEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-modal`, overriding the default "animation".
162-
| `modalLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-modal`, overriding the default "animation".
163-
| `mode` | `Mode` | The mode determines which platform styles to use for the whole application.
164-
| `navAnimation` | `AnimationBuilder` | Overrides the default "animation" of all `ion-nav` and `ion-router-outlet` across the whole application.
165-
| `pickerEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-picker`, overriding the default "animation".
166-
| `pickerLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-picker`, overriding the default "animation".
167-
| `popoverEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-popover`, overriding the default "animation".
168-
| `popoverLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-popover`, overriding the default "animation".
169-
| `refreshingIcon` | `string` | Overrides the default icon in all `<ion-refresh-content>` components.
170-
| `refreshingSpinner` | `SpinnerTypes` | Overrides the default spinner type in all `<ion-refresh-content>` components.
171-
| `sanitizerEnabled` | `boolean` | If `true`, Ionic will enable a basic DOM sanitizer on component properties that accept custom HTML.
172-
| `spinner` | `SpinnerTypes` | Overrides the default spinner in all `<ion-spinner>` components.
173-
| `statusTap` | `boolean` | If `true`, clicking or tapping the status bar will cause the content to scroll to the top.
174-
| `swipeBackEnabled` | `boolean` | If `true`, Ionic will enable the "swipe-to-go-back" gesture across the application.
175-
| `tabButtonLayout` | `TabButtonLayout` | Overrides the default "layout" of all `ion-bar-button` across the whole application.
176-
| `toastEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-toast`, overriding the default "animation".
177-
| `toastLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-toast`, overriding the default "animation".
144+
| ------------------------ | ------------------ | -------------------------------------------------------------------------------------------------------- |
145+
| `actionSheetEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-action-sheet`, overriding the default "animation". |
146+
| `actionSheetLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-action-sheet`, overriding the default "animation". |
147+
| `alertEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-alert`, overriding the default "animation". |
148+
| `alertLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-alert`, overriding the default "animation". |
149+
| `animated` | `boolean` | If `true`, Ionic will enable all animations and transitions across the app. |
150+
| `backButtonIcon` | `string` | Overrides the default icon in all `<ion-back-button>` components. |
151+
| `backButtonText` | `string` | Overrides the default text in all `<ion-back-button>` components. |
152+
| `hardwareBackButton` | `boolean` | If `true`, Ionic will respond to the hardware back button in an Android device. |
153+
| `infiniteLoadingSpinner` | `SpinnerTypes` | Overrides the default spinner type in all `<ion-infinite-scroll-content>` components. |
154+
| `loadingEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-loading`, overriding the default "animation". |
155+
| `loadingLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-loading`, overriding the default "animation". |
156+
| `loadingSpinner` | `SpinnerTypes` | Overrides the default spinner for all `ion-loading` overlays. |
157+
| `menuIcon` | `string` | Overrides the default icon in all `<ion-menu-button>` components. |
158+
| `menuType` | `string` | Overrides the default menu type for all `<ion-menu>` components. |
159+
| `modalEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-modal`, overriding the default "animation". |
160+
| `modalLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-modal`, overriding the default "animation". |
161+
| `mode` | `Mode` | The mode determines which platform styles to use for the whole application. |
162+
| `navAnimation` | `AnimationBuilder` | Overrides the default "animation" of all `ion-nav` and `ion-router-outlet` across the whole application. |
163+
| `pickerEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-picker`, overriding the default "animation". |
164+
| `pickerLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-picker`, overriding the default "animation". |
165+
| `popoverEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-popover`, overriding the default "animation". |
166+
| `popoverLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-popover`, overriding the default "animation". |
167+
| `refreshingIcon` | `string` | Overrides the default icon in all `<ion-refresh-content>` components. |
168+
| `refreshingSpinner` | `SpinnerTypes` | Overrides the default spinner type in all `<ion-refresh-content>` components. |
169+
| `sanitizerEnabled` | `boolean` | If `true`, Ionic will enable a basic DOM sanitizer on component properties that accept custom HTML. |
170+
| `spinner` | `SpinnerTypes` | Overrides the default spinner in all `<ion-spinner>` components. |
171+
| `statusTap` | `boolean` | If `true`, clicking or tapping the status bar will cause the content to scroll to the top. |
172+
| `swipeBackEnabled` | `boolean` | If `true`, Ionic will enable the "swipe-to-go-back" gesture across the application. |
173+
| `tabButtonLayout` | `TabButtonLayout` | Overrides the default "layout" of all `ion-bar-button` across the whole application. |
174+
| `toastEnter` | `AnimationBuilder` | Provides a custom enter animation for all `ion-toast`, overriding the default "animation". |
175+
| `toastLeave` | `AnimationBuilder` | Provides a custom leave animation for all `ion-toast`, overriding the default "animation". |

docs/angular/lifecycle.md

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ sidebar_label: Lifecycle
66

77
This guide covers how the page life cycle works in an app built with Ionic and Angular.
88

9-
109
![Ionic life cycle events demo](/img/guides/lifecycle/ioniclifecycle.png)
1110

1211
## Angular Life Cycle Events
1312

1413
Ionic embraces the life cycle events provided by Angular. The two Angular events you will find using the most are:
1514

16-
17-
| Event Name | Description |
18-
|--------------------|------------------------------------------------------------------|
19-
| `ngOnInit` | Fired once during component initialization. This event can be used to initialize local members and make calls into services that only need to be done once. |
20-
| `ngOnDestroy` | Fired right before Angular destroys the view. Useful for cleanup like unsubscribing from observables. |
15+
| Event Name | Description |
16+
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
17+
| `ngOnInit` | Fired once during component initialization. This event can be used to initialize local members and make calls into services that only need to be done once. |
18+
| `ngOnDestroy` | Fired right before Angular destroys the view. Useful for cleanup like unsubscribing from observables. |
2119

2220
For more info on the Angular Component Life Cycle events, visit their [component lifecycle docs](https://angular.io/guide/lifecycle-hooks).
2321

@@ -29,28 +27,27 @@ Components that use `ion-nav` or `ion-router-outlet` should not use the `OnPush`
2927

3028
In addition to the Angular life cycle events, Ionic Angular provides a few additional events that you can use:
3129

32-
| Event Name | Description |
33-
|--------------------|------------------------------------------------------------------|
30+
| Event Name | Description |
31+
| ------------------ | ------------------------------------------------------------------ |
3432
| `ionViewWillEnter` | Fired when the component routing to is about to animate into view. |
3533
| `ionViewDidEnter` | Fired when the component routing to has finished animating. |
36-
| `ionViewWillLeave` | Fired when the component routing from is about to animate. |
37-
| `ionViewDidLeave` | Fired when the component routing to has finished animating. |
34+
| `ionViewWillLeave` | Fired when the component routing from is about to animate. |
35+
| `ionViewDidLeave` | Fired when the component routing to has finished animating. |
3836

39-
The difference between `ionViewWillEnter` and `ionViewDidEnter` is when they fire. The former fires right after `ngOnInit` but before the page transition begins, and the latter directly after the transition ends.
37+
The difference between `ionViewWillEnter` and `ionViewDidEnter` is when they fire. The former fires right after `ngOnInit` but before the page transition begins, and the latter directly after the transition ends.
4038

4139
For `ionViewWillLeave` and `ionViewDidLeave`, `ionViewWillLeave` gets called directly before the transition away from the current page begins, and `ionViewDidLeave` does not get called until after the new page gets successfully transitioned into (after the new pages `ionViewDidEnter` fires).
4240

43-
4441
![Ionic life cycle events demo](/img/guides/lifecycle/ioniclifecycle.gif)
4542

4643
## How Ionic Handles the Life of a Page
4744

4845
Ionic has its router outlet, called `<ion-router-outlet />`. This outlet extends Angular's `<router-outlet />` with some additional functionality to enable better experiences for mobile devices.
4946

50-
When an app is wrapped in `<ion-router-outlet />`, Ionic treats navigation a bit differently. When you navigate to a new page, Ionic will keep the old page in the existing DOM, but hide it from your view and transition the new page. The reason we do this is two-fold:
47+
When an app is wrapped in `<ion-router-outlet />`, Ionic treats navigation a bit differently. When you navigate to a new page, Ionic will keep the old page in the existing DOM, but hide it from your view and transition the new page. The reason we do this is two-fold:
5148

52-
1) We can maintain the state of the old page (data on the screen, scroll position, etc..)
53-
2) We can provide a smoother transition back to the page since it is already there and doesn't need to be recreated.
49+
1. We can maintain the state of the old page (data on the screen, scroll position, etc..)
50+
2. We can provide a smoother transition back to the page since it is already there and doesn't need to be recreated.
5451

5552
Pages are only removed from the DOM when they are "popped", for instance, by pressing the back button in the UI or the browsers back button.
5653

@@ -62,11 +59,11 @@ Because of this special handling, the `ngOnInit` and `ngOnDestroy` methods might
6259

6360
In Ionic 3, there were a couple of additional life cycle methods that were useful to control when a page could be entered (`ionViewCanEnter`) and left (`ionViewCanLeave`). These could be used to protect pages from unauthorized users and to keep a user on a page when you don't want them to leave (like during a form fill).
6461

65-
These methods were removed in Ionic 4 in favor of using Angular's Route Guards.
62+
These methods were removed in Ionic 4 in favor of using Angular's Route Guards.
6663

6764
A route guard helps determine if a particular action can be taken against a route. They are classes that implement a certain interface. The `CanActivate` and `CanDeactivate` interfaces can be used to implement the same type of logic that the removed events `ionViewCanEnter` and `ionViewCanLeave` did.
6865

69-
```typescript
66+
```tsx
7067
@Injectable()
7168
export class AuthGuard implements CanActivate {
7269
constructor(private authService: AuthService) {}
@@ -79,7 +76,7 @@ export class AuthGuard implements CanActivate {
7976

8077
To use this guard, add it to the appropriate param in the route definition:
8178

82-
```typescript
79+
```tsx
8380
{ path: 'settings', canActivate: [AuthGuard], loadChildren: '...', }
8481
```
8582

@@ -91,14 +88,7 @@ Below are some tips on uses cases for each of the life cycle events.
9188

9289
- `ngOnInit` - Initialize your component and load data from services that don't need refreshing on each subsequent visit.
9390
- `ionViewWillEnter` - Since `ionViewWillEnter` is called every time the view is navigated to (regardless if initialized or not), it's a good method to load data from services. However, if your data comes back during the animation, it can start lots of DOM manipulation, which can cause some janky animations.
94-
- `ionViewDidEnter` - If you see performance problems from using `ionViewWillEnter` when loading data, you can do your data calls in `ionViewDidEnter` instead. This event won't fire until after the page is visible by the user, however, so you might want to use either a loading indicator or a skeleton screen, so content doesn't flash in un-naturally after the transition is complete.
91+
- `ionViewDidEnter` - If you see performance problems from using `ionViewWillEnter` when loading data, you can do your data calls in `ionViewDidEnter` instead. This event won't fire until after the page is visible by the user, however, so you might want to use either a loading indicator or a skeleton screen, so content doesn't flash in un-naturally after the transition is complete.
9592
- `ionViewWillLeave` - Can be used for cleanup, like unsubscribing from observables. Since `ngOnDestroy` might not fire when you navigate from the current page, put your cleanup code here if you don't want it active while the screen is not in view.
9693
- `ionViewDidLeave` - When this event fires, you know the new page has fully transitioned in, so any logic you might not normally do when the view is visible can go here.
9794
- `ngOnDestroy` - Cleanup logic for your pages that you don't want to clean up in `ionViewWillLeave`.
98-
99-
100-
101-
102-
103-
104-

0 commit comments

Comments
 (0)