You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/angular/build-options.md
+93
Original file line number
Diff line number
Diff line change
@@ -113,6 +113,41 @@ export class HomePage {
113
113
}
114
114
```
115
115
116
+
Icons can also be registered in entry points such as `app.component.ts` to avoid the need to call `addIcons` multiple times. Developers should be aware that the initial application chunk may increase because the registered icons will need to be loaded at application start. However, if your application uses a small number of icons the impact of this may be minimal.
117
+
118
+
```typescript title="app.component.ts"
119
+
import { Component } from'@angular/core';
120
+
import { addIcons } from'ionicons';
121
+
import { logoIonic } from'ionicons/icons';
122
+
123
+
@Component({
124
+
selector: 'app-root',
125
+
templateUrl: 'app.component.html',
126
+
styleUrls: ['app.component.scss'],
127
+
standalone: true,
128
+
})
129
+
exportclassAppComponent {
130
+
constructor() {
131
+
/**
132
+
* Any icons you want to use in your application
133
+
* can be registered in app.component.ts and then
134
+
* referenced by name anywhere in your application.
135
+
*/
136
+
addIcons({ logoIonic });
137
+
}
138
+
}
139
+
```
140
+
141
+
Icons registered in an application entry point can then be referenced by name anywhere in the application.
142
+
143
+
```html title="home.page.html"
144
+
<!--
145
+
logoIonic was registered in app.component.ts instead of home.page.ts,
146
+
but it can still be used in home.page.html.
147
+
-->
148
+
<ion-iconname="logo-ionic"></ion-icon>
149
+
```
150
+
116
151
**Routing**
117
152
118
153
Developers who wish to use `routerLink`, `routerAction`, or `routerDirection` on Ionic components should import the `IonRouterLink` directive. Developers who wish to use these routing features on anchor (`<a>`) elements should import `IonRouterLinkWithHref` instead.
@@ -218,6 +253,40 @@ export class HomePage {
218
253
}
219
254
```
220
255
256
+
Icons can also be registered in entry points such as `app.component.ts` to avoid the need to call `addIcons` multiple times. Developers should be aware that the initial application chunk may increase because the registered icons will need to be loaded at application start. However, if your application uses a small number of icons the impact of this may be minimal.
257
+
258
+
```typescript title="app.component.ts"
259
+
import { Component } from'@angular/core';
260
+
import { addIcons } from'ionicons';
261
+
import { logoIonic } from'ionicons/icons';
262
+
263
+
@Component({
264
+
selector: 'app-root',
265
+
templateUrl: 'app.component.html',
266
+
styleUrls: ['app.component.scss'],
267
+
})
268
+
exportclassAppComponent {
269
+
constructor() {
270
+
/**
271
+
* Any icons you want to use in your application
272
+
* can be registered in app.component.ts and then
273
+
* referenced by name anywhere in your application.
274
+
*/
275
+
addIcons({ logoIonic });
276
+
}
277
+
}
278
+
```
279
+
280
+
Icons registered in an application entry point can then be referenced by name anywhere in the application.
281
+
282
+
```html title="home.page.html"
283
+
<!--
284
+
logoIonic was registered in app.component.ts instead of home.page.ts,
285
+
but it can still be used in home.page.html.
286
+
-->
287
+
<ion-iconname="logo-ionic"></ion-icon>
288
+
```
289
+
221
290
**Routing**
222
291
223
292
Developers who wish to use `routerLink`, `routerAction`, or `routerDirection` on Ionic components should import the `IonRouterLink` directive. Developers who wish to use these routing features on anchor (`<a>`) elements should import `IonRouterLinkWithHref` instead.
@@ -283,10 +352,18 @@ export class AppModule {}
283
352
284
353
## Migrating from Modules to Standalone
285
354
355
+
:::tip
356
+
Try our automated utility for migrating to standalone!
357
+
358
+
See https://github.com/ionic-team/ionic-angular-standalone-codemods for instructions on how to get started. All issues related to the migration utility should be filed on the linked repo.
359
+
:::
360
+
286
361
The Standalone option is newer than the Modules option, so developers may wish to switch during the development of their application. This guide details the steps needed to migrate.
287
362
288
363
Migrating to Ionic standalone components must be done all at the same time and cannot be done gradually. The Modules and Standalone approaches use two different build systems of Ionic that cannot be used at the same time.
289
364
365
+
Developers are encouraged to try the [automated migration utility](https://github.com/ionic-team/ionic-angular-standalone-codemods), though they can also follow the steps below if they would like to manually migrate their applications.
366
+
290
367
### Standalone-based Applications
291
368
292
369
Follow these steps if your Angular application is already using the standalone architecture, and you want to use Ionic UI components as standalone components too.
@@ -407,6 +484,14 @@ import { Component } from '@angular/core';
407
484
export class TestComponent {}
408
485
```
409
486
487
+
10. If you are using VSCode it is recommended to ignore the `@ionic/angular/common` and `@ionic/angular` module specifiers for import recommendations.
Follow these steps if your Angular application is still using the NgModule architecture, but you want to adopt Ionic UI components as standalone components now.
@@ -576,3 +661,11 @@ import { TestComponent } from './test.component';
576
661
declarations: [TestComponent]
577
662
})
578
663
```
664
+
665
+
10. If you are using VSCode it is recommended to ignore the `@ionic/angular/common` and `@ionic/angular` module specifiers for import recommendations.
0 commit comments